Project wide syntax/annotation cleanup (#4238)

Co-authored-by: Konicai <71294714+Konicai@users.noreply.github.com>
This commit is contained in:
chris 2023-12-06 00:54:42 +01:00 committed by GitHub
parent 998caee156
commit 95d65350e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
270 changed files with 891 additions and 977 deletions

View File

@ -33,18 +33,14 @@ public class LongClassName {
} }
switch (value) { switch (value) {
case 0: case 0 -> stuff();
stuff(); case 1 -> differentStuff();
break;
case 1:
differentStuff();
break;
} }
} }
} }
``` ```
Make sure to comment your code where possible. Make sure to comment your code where possible. To mark nullable methods, use `@Nullable` (and subsequently, `@NonNull`) from the `org.checkerframework.checker.nullness.qual` package.
The nature of our software requires a lot of arrays and maps to be stored - where possible, use Fastutil's specialized maps. For example, if you're storing block state translations, use an `Int2IntMap`. The nature of our software requires a lot of arrays and maps to be stored - where possible, use Fastutil's specialized maps. For example, if you're storing block state translations, use an `Int2IntMap`.

View File

@ -25,6 +25,8 @@
package org.geysermc.geyser.processor; package org.geysermc.geyser.processor;
import org.checkerframework.checker.nullness.qual.Nullable;
import javax.annotation.processing.AbstractProcessor; import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.ProcessingEnvironment; import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.RoundEnvironment; import javax.annotation.processing.RoundEnvironment;
@ -159,7 +161,7 @@ public class ClassProcessor extends AbstractProcessor {
this.processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, "Completed processing for " + this.annotationClassName); this.processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, "Completed processing for " + this.annotationClassName);
} }
private BufferedReader createReader() throws IOException { private @Nullable BufferedReader createReader() throws IOException {
if (this.outputPath != null) { if (this.outputPath != null) {
this.processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, "Reading existing " + this.annotationClassName + " list from " + this.outputPath); this.processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, "Reading existing " + this.annotationClassName + " list from " + this.outputPath);
return Files.newBufferedReader(this.outputPath); return Files.newBufferedReader(this.outputPath);

View File

@ -77,6 +77,7 @@ public interface GeyserApi extends GeyserApiBase {
* @param apiClass the builder class * @param apiClass the builder class
* @param <R> the implementation type * @param <R> the implementation type
* @param <T> the API type * @param <T> the API type
* @throws IllegalArgumentException if there is no provider for the specified API class
* @return the builder instance * @return the builder instance
*/ */
@NonNull @NonNull

View File

@ -27,5 +27,5 @@ package org.geysermc.geyser.api.bedrock.camera;
public enum CameraShake { public enum CameraShake {
POSITIONAL, POSITIONAL,
ROTATIONAL; ROTATIONAL
} }

View File

@ -25,11 +25,11 @@
package org.geysermc.geyser.api.block.custom.component; package org.geysermc.geyser.api.block.custom.component;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Set; import java.util.Set;
import org.checkerframework.checker.nullness.qual.NonNull;
/** /**
* This class is used to store conditions for a placement filter for a custom block. * This class is used to store conditions for a placement filter for a custom block.
* *
@ -43,7 +43,7 @@ public record PlacementConditions(@NonNull Set<Face> allowedFaces, @NonNull Link
NORTH, NORTH,
SOUTH, SOUTH,
WEST, WEST,
EAST; EAST
} }
public enum BlockFilterType { public enum BlockFilterType {

View File

@ -39,7 +39,7 @@ public interface JavaBlockState {
* *
* @return whether the block state is waterlogged * @return whether the block state is waterlogged
*/ */
@NonNull boolean waterlogged(); boolean waterlogged();
/** /**
* Gets the collision of the block state * Gets the collision of the block state
@ -53,7 +53,7 @@ public interface JavaBlockState {
* *
* @return whether the block state can be broken with hand * @return whether the block state can be broken with hand
*/ */
@NonNull boolean canBreakWithHand(); boolean canBreakWithHand();
/** /**
* Gets the pick item of the block state * Gets the pick item of the block state
@ -74,7 +74,7 @@ public interface JavaBlockState {
* *
* @return whether the block state has block entity * @return whether the block state has block entity
*/ */
@Nullable boolean hasBlockEntity(); boolean hasBlockEntity();
/** /**
* Creates a new {@link JavaBlockState.Builder} instance * Creates a new {@link JavaBlockState.Builder} instance
@ -94,17 +94,17 @@ public interface JavaBlockState {
Builder blockHardness(@NonNegative float blockHardness); Builder blockHardness(@NonNegative float blockHardness);
Builder waterlogged(@NonNull boolean waterlogged); Builder waterlogged(boolean waterlogged);
Builder collision(@NonNull JavaBoundingBox[] collision); Builder collision(@NonNull JavaBoundingBox[] collision);
Builder canBreakWithHand(@NonNull boolean canBreakWithHand); Builder canBreakWithHand(boolean canBreakWithHand);
Builder pickItem(@Nullable String pickItem); Builder pickItem(@Nullable String pickItem);
Builder pistonBehavior(@Nullable String pistonBehavior); Builder pistonBehavior(@Nullable String pistonBehavior);
Builder hasBlockEntity(@Nullable boolean hasBlockEntity); Builder hasBlockEntity(boolean hasBlockEntity);
JavaBlockState build(); JavaBlockState build();
} }

View File

@ -1,6 +1,4 @@
package org.geysermc.geyser.api.block.custom.nonvanilla; package org.geysermc.geyser.api.block.custom.nonvanilla;
import org.checkerframework.checker.nullness.qual.NonNull; public record JavaBoundingBox(double middleX, double middleY, double middleZ, double sizeX, double sizeY, double sizeZ) {
public record JavaBoundingBox(@NonNull double middleX, @NonNull double middleY, @NonNull double middleZ, @NonNull double sizeX, @NonNull double sizeY, @NonNull double sizeZ) {
} }

View File

@ -28,7 +28,6 @@ package org.geysermc.geyser.api.event;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.event.Event; import org.geysermc.event.Event;
import org.geysermc.event.bus.OwnedEventBus; import org.geysermc.event.bus.OwnedEventBus;
import org.geysermc.geyser.api.extension.Extension;
import java.util.Set; import java.util.Set;

View File

@ -27,7 +27,6 @@ package org.geysermc.geyser.api.event;
import org.geysermc.event.Event; import org.geysermc.event.Event;
import org.geysermc.event.subscribe.OwnedSubscriber; import org.geysermc.event.subscribe.OwnedSubscriber;
import org.geysermc.geyser.api.extension.Extension;
/** /**
* Represents a subscribed listener to a {@link Event}. Wraps around * Represents a subscribed listener to a {@link Event}. Wraps around

View File

@ -34,7 +34,7 @@ import java.net.InetSocketAddress;
/** /**
* Called whenever Geyser gets pinged * Called whenever Geyser gets pinged
* * <p>
* This event allows you to modify/obtain the MOTD, maximum player count, and current number of players online, * This event allows you to modify/obtain the MOTD, maximum player count, and current number of players online,
* Geyser will reply to the client with what was given. * Geyser will reply to the client with what was given.
*/ */

View File

@ -33,7 +33,7 @@ import java.util.Map;
/** /**
* Called when commands are defined within Geyser. * Called when commands are defined within Geyser.
* * <p>
* This event allows you to register new commands using the {@link #register(Command)} * This event allows you to register new commands using the {@link #register(Command)}
* method and retrieve the default commands defined. * method and retrieve the default commands defined.
*/ */

View File

@ -28,13 +28,12 @@ package org.geysermc.geyser.api.event.lifecycle;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.geyser.api.block.custom.CustomBlockData; import org.geysermc.geyser.api.block.custom.CustomBlockData;
import org.geysermc.geyser.api.block.custom.CustomBlockState; import org.geysermc.geyser.api.block.custom.CustomBlockState;
import org.geysermc.geyser.api.block.custom.nonvanilla.JavaBlockItem;
import org.geysermc.geyser.api.block.custom.nonvanilla.JavaBlockState; import org.geysermc.geyser.api.block.custom.nonvanilla.JavaBlockState;
import org.geysermc.event.Event; import org.geysermc.event.Event;
/** /**
* Called on Geyser's startup when looking for custom blocks. Custom blocks must be registered through this event. * Called on Geyser's startup when looking for custom blocks. Custom blocks must be registered through this event.
* * <p>
* This event will not be called if the "add-non-bedrock-items" setting is disabled in the Geyser config. * This event will not be called if the "add-non-bedrock-items" setting is disabled in the Geyser config.
*/ */
public abstract class GeyserDefineCustomBlocksEvent implements Event { public abstract class GeyserDefineCustomBlocksEvent implements Event {
@ -48,8 +47,8 @@ public abstract class GeyserDefineCustomBlocksEvent implements Event {
/** /**
* Registers the given {@link CustomBlockState} as an override for the * Registers the given {@link CustomBlockState} as an override for the
* given java state identifier * given java state identifier
* Java state identifiers are listed in * Java state identifiers are listed
* https://raw.githubusercontent.com/GeyserMC/mappings/master/blocks.json * <a href="https://raw.githubusercontent.com/GeyserMC/mappings/master/blocks.json">here</a>
* *
* @param javaIdentifier the java state identifier to override * @param javaIdentifier the java state identifier to override
* @param customBlockState the custom block state with which to override java state identifier * @param customBlockState the custom block state with which to override java state identifier

View File

@ -36,7 +36,7 @@ import java.util.Map;
/** /**
* Called on Geyser's startup when looking for custom items. Custom items must be registered through this event. * Called on Geyser's startup when looking for custom items. Custom items must be registered through this event.
* * <p>
* This event will not be called if the "add non-Bedrock items" setting is disabled in the Geyser config. * This event will not be called if the "add non-Bedrock items" setting is disabled in the Geyser config.
*/ */
public interface GeyserDefineCustomItemsEvent extends Event { public interface GeyserDefineCustomItemsEvent extends Event {

View File

@ -5,7 +5,7 @@ import org.geysermc.event.Event;
/** /**
* Called on Geyser's startup when looking for custom skulls. Custom skulls must be registered through this event. * Called on Geyser's startup when looking for custom skulls. Custom skulls must be registered through this event.
* * <p>
* This event will not be called if the "add-non-bedrock-items" setting is disabled in the Geyser config. * This event will not be called if the "add-non-bedrock-items" setting is disabled in the Geyser config.
*/ */
public abstract class GeyserDefineCustomSkullsEvent implements Event { public abstract class GeyserDefineCustomSkullsEvent implements Event {

View File

@ -25,10 +25,16 @@
package org.geysermc.geyser.api.extension.exception; package org.geysermc.geyser.api.extension.exception;
import java.io.Serial;
/** /**
* Thrown when an extension's description is invalid. * Thrown when an extension's description is invalid.
*/ */
public class InvalidDescriptionException extends Exception { public class InvalidDescriptionException extends Exception {
@Serial
private static final long serialVersionUID = 1L;
public InvalidDescriptionException(Throwable cause) { public InvalidDescriptionException(Throwable cause) {
super(cause); super(cause);
} }

View File

@ -25,10 +25,16 @@
package org.geysermc.geyser.api.extension.exception; package org.geysermc.geyser.api.extension.exception;
import java.io.Serial;
/** /**
* Thrown when an extension is invalid. * Thrown when an extension is invalid.
*/ */
public class InvalidExtensionException extends Exception { public class InvalidExtensionException extends Exception {
@Serial
private static final long serialVersionUID = 1L;
public InvalidExtensionException(Throwable cause) { public InvalidExtensionException(Throwable cause) {
super(cause); super(cause);
} }

View File

@ -51,7 +51,7 @@ public enum CreativeCategory {
* *
* @return the name of the category * @return the name of the category
*/ */
@NonNull public String internalName() { public @NonNull String internalName() {
return internalName; return internalName;
} }

View File

@ -30,7 +30,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
/** /**
* This is a way to represent a boolean, but with a non set value added. * This is a way to represent a boolean, but with a non set value added.
* This class was inspired by adventure's version https://github.com/KyoriPowered/adventure/blob/main/4/api/src/main/java/net/kyori/adventure/util/TriState.java * This class was inspired by adventure's <a href="https://github.com/KyoriPowered/adventure/blob/main/4/api/src/main/java/net/kyori/adventure/util/TriState.java">TriState</a>
*/ */
public enum TriState { public enum TriState {
/** /**

View File

@ -30,6 +30,7 @@ import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.plugin.Plugin; import net.md_5.bungee.api.plugin.Plugin;
import org.geysermc.geyser.dump.BootstrapDumpInfo; import org.geysermc.geyser.dump.BootstrapDumpInfo;
import java.net.InetSocketAddress;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -51,7 +52,8 @@ public class GeyserBungeeDumpInfo extends BootstrapDumpInfo {
this.plugins = new ArrayList<>(); this.plugins = new ArrayList<>();
for (net.md_5.bungee.api.config.ListenerInfo listener : proxy.getConfig().getListeners()) { for (net.md_5.bungee.api.config.ListenerInfo listener : proxy.getConfig().getListeners()) {
this.listeners.add(new ListenerInfo(listener.getHost().getHostString(), listener.getHost().getPort())); InetSocketAddress address = (InetSocketAddress) listener.getSocketAddress();
this.listeners.add(new ListenerInfo(address.getHostString(), address.getPort()));
} }
for (Plugin plugin : proxy.getPluginManager().getPlugins()) { for (Plugin plugin : proxy.getPluginManager().getPlugins()) {

View File

@ -39,6 +39,7 @@ import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.api.plugin.Plugin; import net.md_5.bungee.api.plugin.Plugin;
import net.md_5.bungee.event.EventHandler; import net.md_5.bungee.event.EventHandler;
import net.md_5.bungee.netty.PipelineUtils; import net.md_5.bungee.netty.PipelineUtils;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.geyser.GeyserBootstrap; import org.geysermc.geyser.GeyserBootstrap;
import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.network.netty.GeyserInjector; import org.geysermc.geyser.network.netty.GeyserInjector;
@ -125,7 +126,7 @@ public class GeyserBungeeInjector extends GeyserInjector implements Listener {
.channel(LocalServerChannelWrapper.class) .channel(LocalServerChannelWrapper.class)
.childHandler(new ChannelInitializer<>() { .childHandler(new ChannelInitializer<>() {
@Override @Override
protected void initChannel(Channel ch) throws Exception { protected void initChannel(@NonNull Channel ch) throws Exception {
if (proxy.getConfig().getServers() == null) { if (proxy.getConfig().getServers() == null) {
// Proxy hasn't finished loading all plugins - it loads the config after all plugins // Proxy hasn't finished loading all plugins - it loads the config after all plugins
// Probably doesn't need to be translatable? // Probably doesn't need to be translatable?

View File

@ -35,6 +35,7 @@ import net.md_5.bungee.api.connection.PendingConnection;
import net.md_5.bungee.api.event.ProxyPingEvent; import net.md_5.bungee.api.event.ProxyPingEvent;
import net.md_5.bungee.api.plugin.Listener; import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.protocol.ProtocolConstants; import net.md_5.bungee.protocol.ProtocolConstants;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.geyser.ping.GeyserPingInfo; import org.geysermc.geyser.ping.GeyserPingInfo;
import org.geysermc.geyser.ping.IGeyserPingPassthrough; import org.geysermc.geyser.ping.IGeyserPingPassthrough;
@ -104,7 +105,7 @@ public class GeyserBungeePingPassthrough implements IGeyserPingPassthrough, List
} }
@Override @Override
public InetSocketAddress getVirtualHost() { public @Nullable InetSocketAddress getVirtualHost() {
return null; return null;
} }

View File

@ -30,6 +30,7 @@ import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.api.config.ListenerInfo; import net.md_5.bungee.api.config.ListenerInfo;
import net.md_5.bungee.api.plugin.Plugin; import net.md_5.bungee.api.plugin.Plugin;
import net.md_5.bungee.protocol.ProtocolConstants; import net.md_5.bungee.protocol.ProtocolConstants;
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.util.PlatformType; import org.geysermc.geyser.api.util.PlatformType;
import org.geysermc.geyser.GeyserBootstrap; import org.geysermc.geyser.GeyserBootstrap;
@ -44,7 +45,6 @@ import org.geysermc.geyser.ping.IGeyserPingPassthrough;
import org.geysermc.geyser.platform.bungeecord.command.GeyserBungeeCommandExecutor; import org.geysermc.geyser.platform.bungeecord.command.GeyserBungeeCommandExecutor;
import org.geysermc.geyser.text.GeyserLocale; import org.geysermc.geyser.text.GeyserLocale;
import org.geysermc.geyser.util.FileUtils; import org.geysermc.geyser.util.FileUtils;
import org.jetbrains.annotations.NotNull;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -72,6 +72,7 @@ public class GeyserBungeePlugin extends Plugin implements GeyserBootstrap {
private static boolean INITIALIZED = false; private static boolean INITIALIZED = false;
@SuppressWarnings({"JavaReflectionMemberAccess", "ResultOfMethodCallIgnored"})
@Override @Override
public void onLoad() { public void onLoad() {
GeyserLocale.init(this); GeyserLocale.init(this);
@ -251,7 +252,7 @@ public class GeyserBungeePlugin extends Plugin implements GeyserBootstrap {
return this.geyserInjector.getServerSocketAddress(); return this.geyserInjector.getServerSocketAddress();
} }
@NotNull @NonNull
@Override @Override
public String getServerBindAddress() { public String getServerBindAddress() {
return findCompatibleListener().map(InetSocketAddress::getHostString).orElse(""); return findCompatibleListener().map(InetSocketAddress::getHostString).orElse("");

View File

@ -29,6 +29,7 @@ import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.bungeecord.BungeeComponentSerializer; import net.kyori.adventure.text.serializer.bungeecord.BungeeComponentSerializer;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.geyser.command.GeyserCommandSource; import org.geysermc.geyser.command.GeyserCommandSource;
import org.geysermc.geyser.text.GeyserLocale; import org.geysermc.geyser.text.GeyserLocale;
@ -50,7 +51,7 @@ public class BungeeCommandSource implements GeyserCommandSource {
} }
@Override @Override
public void sendMessage(String message) { public void sendMessage(@NonNull String message) {
handle.sendMessage(TextComponent.fromLegacyText(message)); handle.sendMessage(TextComponent.fromLegacyText(message));
} }

View File

@ -37,6 +37,8 @@ import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands; import net.minecraft.commands.Commands;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.geyser.GeyserBootstrap; import org.geysermc.geyser.GeyserBootstrap;
import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.GeyserLogger;
@ -54,8 +56,6 @@ import org.geysermc.geyser.platform.fabric.command.GeyserFabricCommandExecutor;
import org.geysermc.geyser.platform.fabric.world.GeyserFabricWorldManager; import org.geysermc.geyser.platform.fabric.world.GeyserFabricWorldManager;
import org.geysermc.geyser.text.GeyserLocale; import org.geysermc.geyser.text.GeyserLocale;
import org.geysermc.geyser.util.FileUtils; import org.geysermc.geyser.util.FileUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -251,7 +251,7 @@ public class GeyserFabricMod implements ModInitializer, GeyserBootstrap {
return this.server.getServerVersion(); return this.server.getServerVersion();
} }
@NotNull @NonNull
@Override @Override
public String getServerBindAddress() { public String getServerBindAddress() {
String ip = this.server.getLocalIp(); String ip = this.server.getLocalIp();

View File

@ -30,11 +30,12 @@ import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.command.GeyserCommandSource; import org.geysermc.geyser.command.GeyserCommandSource;
import org.geysermc.geyser.text.ChatColor; import org.geysermc.geyser.text.ChatColor;
import javax.annotation.Nonnull; import java.util.Objects;
public class FabricCommandSender implements GeyserCommandSource { public class FabricCommandSender implements GeyserCommandSource {
@ -50,7 +51,7 @@ public class FabricCommandSender implements GeyserCommandSource {
} }
@Override @Override
public void sendMessage(@Nonnull String message) { public void sendMessage(@NonNull String message) {
if (source.getEntity() instanceof ServerPlayer) { if (source.getEntity() instanceof ServerPlayer) {
((ServerPlayer) source.getEntity()).displayClientMessage(Component.literal(message), false); ((ServerPlayer) source.getEntity()).displayClientMessage(Component.literal(message), false);
} else { } else {
@ -62,7 +63,7 @@ public class FabricCommandSender implements GeyserCommandSource {
public void sendMessage(net.kyori.adventure.text.Component message) { public void sendMessage(net.kyori.adventure.text.Component message) {
if (source.getEntity() instanceof ServerPlayer player) { if (source.getEntity() instanceof ServerPlayer player) {
String decoded = GsonComponentSerializer.gson().serialize(message); String decoded = GsonComponentSerializer.gson().serialize(message);
player.displayClientMessage(Component.Serializer.fromJson(decoded), false); player.displayClientMessage(Objects.requireNonNull(Component.Serializer.fromJson(decoded)), false);
return; return;
} }
GeyserCommandSource.super.sendMessage(message); GeyserCommandSource.super.sendMessage(message);

View File

@ -52,12 +52,12 @@ public class GeyserFabricCommandExecutor extends GeyserCommandExecutor implement
} }
@Override @Override
public int run(CommandContext context) { public int run(CommandContext<CommandSourceStack> context) {
return runWithArgs(context, ""); return runWithArgs(context, "");
} }
public int runWithArgs(CommandContext context, String args) { public int runWithArgs(CommandContext<CommandSourceStack> context, String args) {
CommandSourceStack source = (CommandSourceStack) context.getSource(); CommandSourceStack source = context.getSource();
FabricCommandSender sender = new FabricCommandSender(source); FabricCommandSender sender = new FabricCommandSender(source);
GeyserSession session = getGeyserSession(sender); GeyserSession session = getGeyserSession(sender);
if (!testPermission(source)) { if (!testPermission(source)) {

View File

@ -42,6 +42,8 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.Objects;
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
@Mixin(IntegratedServer.class) @Mixin(IntegratedServer.class)
public class IntegratedServerMixin implements GeyserServerPortGetter { public class IntegratedServerMixin implements GeyserServerPortGetter {
@ -58,6 +60,7 @@ public class IntegratedServerMixin implements GeyserServerPortGetter {
// Ensure player locale has been loaded, in case it's different from Java system language // Ensure player locale has been loaded, in case it's different from Java system language
GeyserLocale.loadGeyserLocale(this.minecraft.options.languageCode); GeyserLocale.loadGeyserLocale(this.minecraft.options.languageCode);
// Give indication that Geyser is loaded // Give indication that Geyser is loaded
Objects.requireNonNull(this.minecraft.player);
this.minecraft.player.displayClientMessage(Component.literal(GeyserLocale.getPlayerLocaleString("geyser.core.start", this.minecraft.player.displayClientMessage(Component.literal(GeyserLocale.getPlayerLocaleString("geyser.core.start",
this.minecraft.options.languageCode, "localhost", String.valueOf(this.publishedPort))), false); this.minecraft.options.languageCode, "localhost", String.valueOf(this.publishedPort))), false);
} }

View File

@ -39,6 +39,7 @@ import net.minecraft.world.level.block.entity.BannerBlockEntity;
import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.LecternBlockEntity; import net.minecraft.world.level.block.entity.LecternBlockEntity;
import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.chunk.LevelChunk;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.math.vector.Vector3i; import org.cloudburstmc.math.vector.Vector3i;
import org.cloudburstmc.nbt.NbtMap; import org.cloudburstmc.nbt.NbtMap;
import org.cloudburstmc.nbt.NbtMapBuilder; import org.cloudburstmc.nbt.NbtMapBuilder;
@ -48,9 +49,9 @@ import org.geysermc.geyser.level.GeyserWorldManager;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.BlockEntityUtils; import org.geysermc.geyser.util.BlockEntityUtils;
import javax.annotation.Nonnull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
public class GeyserFabricWorldManager extends GeyserWorldManager { public class GeyserFabricWorldManager extends GeyserWorldManager {
@ -73,9 +74,11 @@ public class GeyserFabricWorldManager extends GeyserWorldManager {
return; return;
} }
//noinspection resource - level() is just a getter
LevelChunk chunk = player.level().getChunk(x, z); LevelChunk chunk = player.level().getChunk(x, z);
final int chunkBlockX = x << 4; final int chunkBlockX = x << 4;
final int chunkBlockZ = z << 4; final int chunkBlockZ = z << 4;
//noinspection ForLoopReplaceableByForEach - avoid constructing iterator
for (int i = 0; i < blockEntityInfos.size(); i++) { for (int i = 0; i < blockEntityInfos.size(); i++) {
BlockEntityInfo blockEntityInfo = blockEntityInfos.get(i); BlockEntityInfo blockEntityInfo = blockEntityInfos.get(i);
BlockEntity blockEntity = chunk.getBlockEntity(new BlockPos(chunkBlockX + blockEntityInfo.getX(), BlockEntity blockEntity = chunk.getBlockEntity(new BlockPos(chunkBlockX + blockEntityInfo.getX(),
@ -92,7 +95,7 @@ public class GeyserFabricWorldManager extends GeyserWorldManager {
if (player == null) { if (player == null) {
return; return;
} }
//noinspection resource - level() is just a getter
BlockEntity blockEntity = player.level().getBlockEntity(new BlockPos(x, y, z)); BlockEntity blockEntity = player.level().getBlockEntity(new BlockPos(x, y, z));
sendLecternData(session, blockEntity, false); sendLecternData(session, blockEntity, false);
}); });
@ -159,7 +162,7 @@ public class GeyserFabricWorldManager extends GeyserWorldManager {
return GameMode.byId(server.getDefaultGameType().getId()); return GameMode.byId(server.getDefaultGameType().getId());
} }
@Nonnull @NonNull
@Override @Override
public CompletableFuture<com.github.steveice10.opennbt.tag.builtin.CompoundTag> getPickItemNbt(GeyserSession session, int x, int y, int z, boolean addNbtData) { public CompletableFuture<com.github.steveice10.opennbt.tag.builtin.CompoundTag> getPickItemNbt(GeyserSession session, int x, int y, int z, boolean addNbtData) {
CompletableFuture<com.github.steveice10.opennbt.tag.builtin.CompoundTag> future = new CompletableFuture<>(); CompletableFuture<com.github.steveice10.opennbt.tag.builtin.CompoundTag> future = new CompletableFuture<>();
@ -172,6 +175,7 @@ public class GeyserFabricWorldManager extends GeyserWorldManager {
BlockPos pos = new BlockPos(x, y, z); BlockPos pos = new BlockPos(x, y, z);
// Don't create a new block entity if invalid // Don't create a new block entity if invalid
//noinspection resource - level() is just a getter
BlockEntity blockEntity = player.level().getChunkAt(pos).getBlockEntity(pos); BlockEntity blockEntity = player.level().getChunkAt(pos).getBlockEntity(pos);
if (blockEntity instanceof BannerBlockEntity banner) { if (blockEntity instanceof BannerBlockEntity banner) {
// Potentially exposes other NBT data? But we need to get the NBT data for the banner patterns *and* // Potentially exposes other NBT data? But we need to get the NBT data for the banner patterns *and*
@ -263,7 +267,7 @@ public class GeyserFabricWorldManager extends GeyserWorldManager {
} }
@Override @Override
public void visitCompound(CompoundTag compoundTag) { public void visitCompound(@NonNull CompoundTag compoundTag) {
currentTag = convert(currentKey, compoundTag); currentTag = convert(currentKey, compoundTag);
} }
@ -271,7 +275,7 @@ public class GeyserFabricWorldManager extends GeyserWorldManager {
OpenNbtTagVisitor visitor = new OpenNbtTagVisitor(name); OpenNbtTagVisitor visitor = new OpenNbtTagVisitor(name);
for (String key : compoundTag.getAllKeys()) { for (String key : compoundTag.getAllKeys()) {
visitor.currentKey = key; visitor.currentKey = key;
Tag tag = compoundTag.get(key); Tag tag = Objects.requireNonNull(compoundTag.get(key));
tag.accept(visitor); tag.accept(visitor);
visitor.root.put(visitor.currentTag); visitor.root.put(visitor.currentTag);
} }
@ -279,7 +283,7 @@ public class GeyserFabricWorldManager extends GeyserWorldManager {
} }
@Override @Override
public void visitEnd(EndTag endTag) { public void visitEnd(@NonNull EndTag endTag) {
} }
} }
} }

View File

@ -28,11 +28,11 @@ package org.geysermc.geyser.platform.spigot;
import com.destroystokyo.paper.event.server.PaperServerListPingEvent; import com.destroystokyo.paper.event.server.PaperServerListPingEvent;
import com.destroystokyo.paper.network.StatusClient; import com.destroystokyo.paper.network.StatusClient;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.geyser.network.GameProtocol; import org.geysermc.geyser.network.GameProtocol;
import org.geysermc.geyser.ping.GeyserPingInfo; import org.geysermc.geyser.ping.GeyserPingInfo;
import org.geysermc.geyser.ping.IGeyserPingPassthrough; import org.geysermc.geyser.ping.IGeyserPingPassthrough;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
@ -50,6 +50,7 @@ public final class GeyserPaperPingPassthrough implements IGeyserPingPassthrough
this.logger = logger; this.logger = logger;
} }
@SuppressWarnings("deprecation")
@Nullable @Nullable
@Override @Override
public GeyserPingInfo getPingInformation(InetSocketAddress inetSocketAddress) { public GeyserPingInfo getPingInformation(InetSocketAddress inetSocketAddress) {
@ -89,7 +90,7 @@ public final class GeyserPaperPingPassthrough implements IGeyserPingPassthrough
private record GeyserStatusClient(InetSocketAddress address) implements StatusClient { private record GeyserStatusClient(InetSocketAddress address) implements StatusClient {
@Override @Override
public @NotNull InetSocketAddress getAddress() { public @NonNull InetSocketAddress getAddress() {
return address; return address;
} }

View File

@ -34,7 +34,7 @@ import org.geysermc.geyser.GeyserImpl;
/** /**
* Disables the compression packet (and the compression handlers from being added to the pipeline) for Geyser clients * Disables the compression packet (and the compression handlers from being added to the pipeline) for Geyser clients
* that won't be receiving the data over the network. * that won't be receiving the data over the network.
* * <p>
* As of 1.8 - 1.17.1, compression is enabled in the Netty pipeline by adding a listener after a packet is written. * As of 1.8 - 1.17.1, compression is enabled in the Netty pipeline by adding a listener after a packet is written.
* If we simply "cancel" or don't forward the packet, then the listener is never called. * If we simply "cancel" or don't forward the packet, then the listener is never called.
*/ */

View File

@ -47,6 +47,7 @@ public class GeyserSpigotDumpInfo extends BootstrapDumpInfo {
private final int serverPort; private final int serverPort;
private final List<PluginInfo> plugins; private final List<PluginInfo> plugins;
@SuppressWarnings("deprecation")
GeyserSpigotDumpInfo() { GeyserSpigotDumpInfo() {
super(); super();
this.platformName = Bukkit.getName(); this.platformName = Bukkit.getName();

View File

@ -32,6 +32,7 @@ import io.netty.channel.*;
import io.netty.channel.local.LocalAddress; import io.netty.channel.local.LocalAddress;
import io.netty.util.concurrent.DefaultThreadFactory; import io.netty.util.concurrent.DefaultThreadFactory;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.geyser.GeyserBootstrap; import org.geysermc.geyser.GeyserBootstrap;
import org.geysermc.geyser.network.netty.GeyserInjector; import org.geysermc.geyser.network.netty.GeyserInjector;
import org.geysermc.geyser.network.netty.LocalServerChannelWrapper; import org.geysermc.geyser.network.netty.LocalServerChannelWrapper;
@ -74,7 +75,6 @@ public class GeyserSpigotInjector extends GeyserInjector {
Object connection = null; Object connection = null;
// Find the class that manages network IO // Find the class that manages network IO
for (Method m : serverClazz.getDeclaredMethods()) { for (Method m : serverClazz.getDeclaredMethods()) {
if (m.getReturnType() != null) {
// First is Spigot-mapped name, second is Mojang-mapped name which is implemented as future-proofing // First is Spigot-mapped name, second is Mojang-mapped name which is implemented as future-proofing
if (m.getReturnType().getSimpleName().equals("ServerConnection") || m.getReturnType().getSimpleName().equals("ServerConnectionListener")) { if (m.getReturnType().getSimpleName().equals("ServerConnection") || m.getReturnType().getSimpleName().equals("ServerConnectionListener")) {
if (m.getParameterTypes().length == 0) { if (m.getParameterTypes().length == 0) {
@ -82,7 +82,6 @@ public class GeyserSpigotInjector extends GeyserInjector {
} }
} }
} }
}
if (connection == null) { if (connection == null) {
throw new RuntimeException("Unable to find ServerConnection class!"); throw new RuntimeException("Unable to find ServerConnection class!");
} }
@ -117,7 +116,7 @@ public class GeyserSpigotInjector extends GeyserInjector {
.channel(LocalServerChannelWrapper.class) .channel(LocalServerChannelWrapper.class)
.childHandler(new ChannelInitializer<>() { .childHandler(new ChannelInitializer<>() {
@Override @Override
protected void initChannel(Channel ch) throws Exception { protected void initChannel(@NonNull Channel ch) throws Exception {
initChannel.invoke(childHandler, ch); initChannel.invoke(childHandler, ch);
if (bootstrap.getGeyserConfig().isDisableCompression() && GeyserSpigotCompressionDisabler.ENABLED) { if (bootstrap.getGeyserConfig().isDisableCompression() && GeyserSpigotCompressionDisabler.ENABLED) {

View File

@ -30,10 +30,12 @@ import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.server.ServerListPingEvent; import org.bukkit.event.server.ServerListPingEvent;
import org.bukkit.util.CachedServerIcon; import org.bukkit.util.CachedServerIcon;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.geyser.network.GameProtocol;
import org.geysermc.geyser.ping.GeyserPingInfo; import org.geysermc.geyser.ping.GeyserPingInfo;
import org.geysermc.geyser.ping.IGeyserPingPassthrough; import org.geysermc.geyser.ping.IGeyserPingPassthrough;
import javax.annotation.Nonnull;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.util.Collections; import java.util.Collections;
@ -44,8 +46,9 @@ public class GeyserSpigotPingPassthrough implements IGeyserPingPassthrough {
private final GeyserSpigotLogger logger; private final GeyserSpigotLogger logger;
@SuppressWarnings("deprecation")
@Override @Override
public GeyserPingInfo getPingInformation(InetSocketAddress inetSocketAddress) { public @Nullable GeyserPingInfo getPingInformation(InetSocketAddress inetSocketAddress) {
try { try {
ServerListPingEvent event = new GeyserPingEvent(inetSocketAddress.getAddress(), Bukkit.getMotd(), Bukkit.getOnlinePlayers().size(), Bukkit.getMaxPlayers()); ServerListPingEvent event = new GeyserPingEvent(inetSocketAddress.getAddress(), Bukkit.getMotd(), Bukkit.getOnlinePlayers().size(), Bukkit.getMaxPlayers());
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
@ -67,7 +70,7 @@ public class GeyserSpigotPingPassthrough implements IGeyserPingPassthrough {
public void setServerIcon(CachedServerIcon icon) throws IllegalArgumentException, UnsupportedOperationException { public void setServerIcon(CachedServerIcon icon) throws IllegalArgumentException, UnsupportedOperationException {
} }
@Nonnull @NonNull
@Override @Override
public Iterator<Player> iterator() throws UnsupportedOperationException { public Iterator<Player> iterator() throws UnsupportedOperationException {
return Collections.emptyIterator(); return Collections.emptyIterator();

View File

@ -42,13 +42,14 @@ import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault; import org.bukkit.permissions.PermissionDefault;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.geysermc.geyser.api.util.PlatformType; import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.geyser.Constants; import org.geysermc.geyser.Constants;
import org.geysermc.geyser.GeyserBootstrap; import org.geysermc.geyser.GeyserBootstrap;
import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.adapters.spigot.SpigotAdapters; import org.geysermc.geyser.adapters.spigot.SpigotAdapters;
import org.geysermc.geyser.api.command.Command; import org.geysermc.geyser.api.command.Command;
import org.geysermc.geyser.api.extension.Extension; import org.geysermc.geyser.api.extension.Extension;
import org.geysermc.geyser.api.util.PlatformType;
import org.geysermc.geyser.command.GeyserCommandManager; import org.geysermc.geyser.command.GeyserCommandManager;
import org.geysermc.geyser.configuration.GeyserConfiguration; import org.geysermc.geyser.configuration.GeyserConfiguration;
import org.geysermc.geyser.dump.BootstrapDumpInfo; import org.geysermc.geyser.dump.BootstrapDumpInfo;
@ -66,7 +67,6 @@ import org.geysermc.geyser.platform.spigot.world.manager.GeyserSpigotNativeWorld
import org.geysermc.geyser.platform.spigot.world.manager.GeyserSpigotWorldManager; import org.geysermc.geyser.platform.spigot.world.manager.GeyserSpigotWorldManager;
import org.geysermc.geyser.text.GeyserLocale; import org.geysermc.geyser.text.GeyserLocale;
import org.geysermc.geyser.util.FileUtils; import org.geysermc.geyser.util.FileUtils;
import org.jetbrains.annotations.NotNull;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -76,6 +76,7 @@ import java.net.SocketAddress;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.UUID; import java.util.UUID;
import java.util.logging.Level; import java.util.logging.Level;
@ -137,6 +138,7 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap {
// This is manually done instead of using Bukkit methods to save the config because otherwise comments get removed // This is manually done instead of using Bukkit methods to save the config because otherwise comments get removed
try { try {
if (!getDataFolder().exists()) { if (!getDataFolder().exists()) {
//noinspection ResultOfMethodCallIgnored
getDataFolder().mkdir(); getDataFolder().mkdir();
} }
File configFile = FileUtils.fileOrCopiedFromResource(new File(getDataFolder(), "config.yml"), "config.yml", File configFile = FileUtils.fileOrCopiedFromResource(new File(getDataFolder(), "config.yml"), "config.yml",
@ -272,6 +274,7 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap {
} }
PluginCommand geyserCommand = this.getCommand("geyser"); PluginCommand geyserCommand = this.getCommand("geyser");
Objects.requireNonNull(geyserCommand, "base command cannot be null");
geyserCommand.setExecutor(new GeyserSpigotCommandExecutor(geyser, geyserCommandManager.getCommands())); geyserCommand.setExecutor(new GeyserSpigotCommandExecutor(geyser, geyserCommandManager.getCommands()));
for (Map.Entry<Extension, Map<String, Command>> entry : this.geyserCommandManager.extensionCommands().entrySet()) { for (Map.Entry<Extension, Map<String, Command>> entry : this.geyserCommandManager.extensionCommands().entrySet()) {
@ -437,7 +440,7 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap {
return false; return false;
} }
@NotNull @NonNull
@Override @Override
public String getServerBindAddress() { public String getServerBindAddress() {
return Bukkit.getIp(); return Bukkit.getIp();

View File

@ -39,6 +39,7 @@ import java.lang.reflect.Modifier;
public final class GeyserSpigotVersionChecker { public final class GeyserSpigotVersionChecker {
private static final String VIAVERSION_DOWNLOAD_URL = "https://ci.viaversion.com/job/ViaVersion/"; private static final String VIAVERSION_DOWNLOAD_URL = "https://ci.viaversion.com/job/ViaVersion/";
@SuppressWarnings("deprecation")
public static void checkForSupportedProtocol(GeyserLogger logger, boolean viaversion) { public static void checkForSupportedProtocol(GeyserLogger logger, boolean viaversion) {
if (viaversion) { if (viaversion) {
checkViaVersionSupportedVersions(logger); checkViaVersionSupportedVersions(logger);

View File

@ -28,8 +28,8 @@ package org.geysermc.geyser.platform.spigot;
import com.github.steveice10.mc.protocol.data.DefaultComponentSerializer; import com.github.steveice10.mc.protocol.data.DefaultComponentSerializer;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserImpl;
import org.jetbrains.annotations.Nullable;
import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodHandles;
@ -39,8 +39,8 @@ import java.lang.reflect.Method;
/** /**
* Utility class for converting our shaded Adventure into the Adventure bundled in Paper. * Utility class for converting our shaded Adventure into the Adventure bundled in Paper.
* * <p>
* Code mostly taken from https://github.com/KyoriPowered/adventure-platform/blob/94d5821f2e755170f42bd8a5fe1d5bf6f66d04ad/platform-bukkit/src/main/java/net/kyori/adventure/platform/bukkit/PaperFacet.java#L46 * Code mostly taken from <a href="https://github.com/KyoriPowered/adventure-platform/blob/94d5821f2e755170f42bd8a5fe1d5bf6f66d04ad/platform-bukkit/src/main/java/net/kyori/adventure/platform/bukkit/PaperFacet.java#L46">here</a>
* and the MinecraftReflection class. * and the MinecraftReflection class.
*/ */
public final class PaperAdventure { public final class PaperAdventure {
@ -102,7 +102,7 @@ public final class PaperAdventure {
SEND_MESSAGE_COMPONENT = playerComponentSendMessage; SEND_MESSAGE_COMPONENT = playerComponentSendMessage;
} }
public static Object toNativeComponent(final Component component) { public static @Nullable Object toNativeComponent(final Component component) {
if (NATIVE_GSON_COMPONENT_SERIALIZER_DESERIALIZE_METHOD_BOUND == null) { if (NATIVE_GSON_COMPONENT_SERIALIZER_DESERIALIZE_METHOD_BOUND == null) {
GeyserImpl.getInstance().getLogger().error("Illegal state where Component serialization was called when it wasn't available!"); GeyserImpl.getInstance().getLogger().error("Illegal state where Component serialization was called when it wasn't available!");
return null; return null;

View File

@ -29,8 +29,8 @@ import com.destroystokyo.paper.event.server.PaperServerListPingEvent;
import com.destroystokyo.paper.network.StatusClient; import com.destroystokyo.paper.network.StatusClient;
import org.bukkit.event.server.ServerListPingEvent; import org.bukkit.event.server.ServerListPingEvent;
import org.bukkit.util.CachedServerIcon; import org.bukkit.util.CachedServerIcon;
import org.checkerframework.checker.nullness.qual.Nullable;
import javax.annotation.Nullable;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.net.InetAddress; import java.net.InetAddress;
@ -40,15 +40,8 @@ import java.net.InetAddress;
public final class ReflectedNames { public final class ReflectedNames {
static boolean checkPaperPingEvent() { static boolean checkPaperPingEvent() {
return classExists("com.destroystokyo.paper.event.server.PaperServerListPingEvent");
}
/**
* @return if this class name exists
*/
private static boolean classExists(String clazz) {
try { try {
Class.forName(clazz); Class.forName("com.destroystokyo.paper.event.server.PaperServerListPingEvent");
return true; return true;
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
return false; return false;
@ -59,7 +52,7 @@ public final class ReflectedNames {
return getConstructor(ServerListPingEvent.class, InetAddress.class, String.class, boolean.class, int.class, int.class) != null; return getConstructor(ServerListPingEvent.class, InetAddress.class, String.class, boolean.class, int.class, int.class) != null;
} }
static Constructor<PaperServerListPingEvent> getOldPaperPingConstructor() { static @Nullable Constructor<PaperServerListPingEvent> getOldPaperPingConstructor() {
if (getConstructor(PaperServerListPingEvent.class, StatusClient.class, String.class, int.class, if (getConstructor(PaperServerListPingEvent.class, StatusClient.class, String.class, int.class,
int.class, String.class, int.class, CachedServerIcon.class) != null) { int.class, String.class, int.class, CachedServerIcon.class) != null) {
// @NotNull StatusClient client, @NotNull String motd, int numPlayers, int maxPlayers, // @NotNull StatusClient client, @NotNull String motd, int numPlayers, int maxPlayers,

View File

@ -39,8 +39,8 @@ import java.util.Map;
public final class GeyserPaperCommandListener implements Listener { public final class GeyserPaperCommandListener implements Listener {
@SuppressWarnings("UnstableApiUsage")
@EventHandler @EventHandler
@SuppressWarnings("deprecation") // Used to indicate an unstable event
public void onCommandSend(AsyncPlayerSendCommandsEvent<?> event) { public void onCommandSend(AsyncPlayerSendCommandsEvent<?> event) {
// Documentation says to check (event.isAsynchronous() || !event.hasFiredAsync()), but as of Paper 1.18.2 // Documentation says to check (event.isAsynchronous() || !event.hasFiredAsync()), but as of Paper 1.18.2
// event.hasFiredAsync is never true // event.hasFiredAsync is never true

View File

@ -29,6 +29,7 @@ import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor; import org.bukkit.command.TabExecutor;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.command.GeyserCommand; import org.geysermc.geyser.command.GeyserCommand;
import org.geysermc.geyser.command.GeyserCommandExecutor; import org.geysermc.geyser.command.GeyserCommandExecutor;
@ -47,7 +48,7 @@ public class GeyserSpigotCommandExecutor extends GeyserCommandExecutor implement
} }
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(@NonNull CommandSender sender, @NonNull Command command, @NonNull String label, String[] args) {
SpigotCommandSource commandSender = new SpigotCommandSource(sender); SpigotCommandSource commandSender = new SpigotCommandSource(sender);
GeyserSession session = getGeyserSession(commandSender); GeyserSession session = getGeyserSession(commandSender);
@ -78,7 +79,7 @@ public class GeyserSpigotCommandExecutor extends GeyserCommandExecutor implement
} }
@Override @Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) { public List<String> onTabComplete(@NonNull CommandSender sender, @NonNull Command command, @NonNull String label, String[] args) {
if (args.length == 1) { if (args.length == 1) {
return tabComplete(new SpigotCommandSource(sender)); return tabComplete(new SpigotCommandSource(sender));
} }

View File

@ -29,6 +29,7 @@ import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.bungeecord.BungeeComponentSerializer; import net.kyori.adventure.text.serializer.bungeecord.BungeeComponentSerializer;
import org.bukkit.command.ConsoleCommandSender; import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.geyser.command.GeyserCommandSource; import org.geysermc.geyser.command.GeyserCommandSource;
import org.geysermc.geyser.platform.spigot.PaperAdventure; import org.geysermc.geyser.platform.spigot.PaperAdventure;
import org.geysermc.geyser.text.GeyserLocale; import org.geysermc.geyser.text.GeyserLocale;
@ -48,10 +49,11 @@ public class SpigotCommandSource implements GeyserCommandSource {
} }
@Override @Override
public void sendMessage(String message) { public void sendMessage(@NonNull String message) {
handle.sendMessage(message); handle.sendMessage(message);
} }
@SuppressWarnings("deprecation")
@Override @Override
public void sendMessage(Component message) { public void sendMessage(Component message) {
if (PaperAdventure.canSendMessageUsingComponent()) { if (PaperAdventure.canSendMessageUsingComponent()) {
@ -68,9 +70,11 @@ public class SpigotCommandSource implements GeyserCommandSource {
return handle instanceof ConsoleCommandSender; return handle instanceof ConsoleCommandSender;
} }
@SuppressWarnings("deprecation")
@Override @Override
public String locale() { public String locale() {
if (this.handle instanceof Player player) { if (this.handle instanceof Player player) {
// getLocale() is deprecated on Paper, but not on Spigot
return player.getLocale(); return player.getLocale();
} }

View File

@ -37,6 +37,7 @@ import org.geysermc.geyser.platform.spigot.GeyserSpigotPlugin;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
import java.util.List; import java.util.List;
import java.util.Objects;
/** /**
* Used when block IDs need to be translated to the latest version * Used when block IDs need to be translated to the latest version
@ -52,6 +53,7 @@ public class GeyserSpigotLegacyNativeWorldManager extends GeyserSpigotNativeWorl
ProtocolVersion serverVersion = plugin.getServerProtocolVersion(); ProtocolVersion serverVersion = plugin.getServerProtocolVersion();
List<ProtocolPathEntry> protocolList = Via.getManager().getProtocolManager().getProtocolPath(GameProtocol.getJavaProtocolVersion(), List<ProtocolPathEntry> protocolList = Via.getManager().getProtocolManager().getProtocolPath(GameProtocol.getJavaProtocolVersion(),
serverVersion.getVersion()); serverVersion.getVersion());
Objects.requireNonNull(protocolList, "protocolList cannot be null");
for (int oldBlockId : allBlockStates) { for (int oldBlockId : allBlockStates) {
int newBlockId = oldBlockId; int newBlockId = oldBlockId;
// protocolList should *not* be null; we checked for that before initializing this class // protocolList should *not* be null; we checked for that before initializing this class

View File

@ -28,11 +28,11 @@ package org.geysermc.geyser.platform.spigot.world.manager;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.geyser.adapters.spigot.SpigotAdapters; import org.geysermc.geyser.adapters.spigot.SpigotAdapters;
import org.geysermc.geyser.adapters.spigot.SpigotWorldAdapter; import org.geysermc.geyser.adapters.spigot.SpigotWorldAdapter;
import org.geysermc.geyser.level.block.BlockStateValues; import org.geysermc.geyser.level.block.BlockStateValues;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
import org.jetbrains.annotations.Nullable;
public class GeyserSpigotNativeWorldManager extends GeyserSpigotWorldManager { public class GeyserSpigotNativeWorldManager extends GeyserSpigotWorldManager {
protected final SpigotWorldAdapter adapter; protected final SpigotWorldAdapter adapter;

View File

@ -34,21 +34,23 @@ import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.cloudburstmc.nbt.NbtMap; import org.cloudburstmc.nbt.NbtMap;
import org.geysermc.erosion.bukkit.BukkitLecterns; import org.geysermc.erosion.bukkit.BukkitLecterns;
import org.geysermc.erosion.bukkit.BukkitUtils; import org.geysermc.erosion.bukkit.BukkitUtils;
import org.geysermc.erosion.bukkit.PickBlockUtils; import org.geysermc.erosion.bukkit.PickBlockUtils;
import org.geysermc.erosion.bukkit.SchedulerUtils; import org.geysermc.erosion.bukkit.SchedulerUtils;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.level.GameRule; import org.geysermc.geyser.level.GameRule;
import org.geysermc.geyser.level.WorldManager; import org.geysermc.geyser.level.WorldManager;
import org.geysermc.geyser.level.block.BlockStateValues; import org.geysermc.geyser.level.block.BlockStateValues;
import org.geysermc.geyser.registry.BlockRegistries; import org.geysermc.geyser.registry.BlockRegistries;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.BlockEntityUtils; import org.geysermc.geyser.util.BlockEntityUtils;
import org.jetbrains.annotations.Nullable;
import javax.annotation.Nonnull;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
/** /**
@ -128,7 +130,7 @@ public class GeyserSpigotWorldManager extends WorldManager {
} }
} }
private Chunk getChunk(World world, int x, int z) { private @Nullable Chunk getChunk(World world, int x, int z) {
if (!world.isChunkLoaded(x, z)) { if (!world.isChunkLoaded(x, z)) {
return null; return null;
} }
@ -136,6 +138,7 @@ public class GeyserSpigotWorldManager extends WorldManager {
} }
private void sendLecternData(GeyserSession session, Chunk chunk, List<BlockEntityInfo> blockEntityInfos) { private void sendLecternData(GeyserSession session, Chunk chunk, List<BlockEntityInfo> blockEntityInfos) {
//noinspection ForLoopReplaceableByForEach - avoid constructing Iterator
for (int i = 0; i < blockEntityInfos.size(); i++) { for (int i = 0; i < blockEntityInfos.size(); i++) {
BlockEntityInfo info = blockEntityInfos.get(i); BlockEntityInfo info = blockEntityInfos.get(i);
Block block = chunk.getBlock(info.getX(), info.getY(), info.getZ()); Block block = chunk.getBlock(info.getX(), info.getY(), info.getZ());
@ -156,19 +159,34 @@ public class GeyserSpigotWorldManager extends WorldManager {
} }
public boolean getGameRuleBool(GeyserSession session, GameRule gameRule) { public boolean getGameRuleBool(GeyserSession session, GameRule gameRule) {
String value = Bukkit.getPlayer(session.getPlayerEntity().getUsername()).getWorld().getGameRuleValue(gameRule.getJavaID()); org.bukkit.GameRule<?> bukkitGameRule = org.bukkit.GameRule.getByName(gameRule.getJavaID());
if (!value.isEmpty()) { if (bukkitGameRule == null) {
return Boolean.parseBoolean(value); GeyserImpl.getInstance().getLogger().debug("Unknown game rule " + gameRule.getJavaID());
return gameRule.getDefaultBooleanValue();
} }
Player bukkitPlayer = Objects.requireNonNull(Bukkit.getPlayer(session.getPlayerEntity().getUuid()));
Object value = bukkitPlayer.getWorld().getGameRuleValue(bukkitGameRule);
if (value instanceof Boolean booleanValue) {
return booleanValue;
}
GeyserImpl.getInstance().getLogger().debug("Expected a bool for " + gameRule + " but got " + value);
return gameRule.getDefaultBooleanValue(); return gameRule.getDefaultBooleanValue();
} }
@Override @Override
public int getGameRuleInt(GeyserSession session, GameRule gameRule) { public int getGameRuleInt(GeyserSession session, GameRule gameRule) {
String value = Bukkit.getPlayer(session.getPlayerEntity().getUsername()).getWorld().getGameRuleValue(gameRule.getJavaID()); org.bukkit.GameRule<?> bukkitGameRule = org.bukkit.GameRule.getByName(gameRule.getJavaID());
if (!value.isEmpty()) { if (bukkitGameRule == null) {
return Integer.parseInt(value); GeyserImpl.getInstance().getLogger().debug("Unknown game rule " + gameRule.getJavaID());
return gameRule.getDefaultIntValue();
} }
Player bukkitPlayer = Objects.requireNonNull(Bukkit.getPlayer(session.getPlayerEntity().getUuid()));
Object value = bukkitPlayer.getWorld().getGameRuleValue(bukkitGameRule);
if (value instanceof Integer intValue) {
return intValue;
}
GeyserImpl.getInstance().getLogger().debug("Expected an int for " + gameRule + " but got " + value);
return gameRule.getDefaultIntValue(); return gameRule.getDefaultIntValue();
} }
@ -179,12 +197,11 @@ public class GeyserSpigotWorldManager extends WorldManager {
@Override @Override
public boolean hasPermission(GeyserSession session, String permission) { public boolean hasPermission(GeyserSession session, String permission) {
return Bukkit.getPlayer(session.getPlayerEntity().getUsername()).hasPermission(permission); return Objects.requireNonNull(Bukkit.getPlayer(session.getPlayerEntity().getUsername())).hasPermission(permission);
} }
@Nonnull
@Override @Override
public CompletableFuture<@Nullable CompoundTag> getPickItemNbt(GeyserSession session, int x, int y, int z, boolean addNbtData) { public @NonNull CompletableFuture<@Nullable CompoundTag> getPickItemNbt(GeyserSession session, int x, int y, int z, boolean addNbtData) {
CompletableFuture<@Nullable CompoundTag> future = new CompletableFuture<>(); CompletableFuture<@Nullable CompoundTag> future = new CompletableFuture<>();
Player bukkitPlayer; Player bukkitPlayer;
if ((bukkitPlayer = Bukkit.getPlayer(session.getPlayerEntity().getUuid())) == null) { if ((bukkitPlayer = Bukkit.getPlayer(session.getPlayerEntity().getUuid())) == null) {

View File

@ -38,6 +38,7 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.Appender; import org.apache.logging.log4j.core.Appender;
import org.apache.logging.log4j.core.Logger; import org.apache.logging.log4j.core.Logger;
import org.apache.logging.log4j.core.appender.ConsoleAppender; import org.apache.logging.log4j.core.appender.ConsoleAppender;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.geyser.api.util.PlatformType; import org.geysermc.geyser.api.util.PlatformType;
import org.geysermc.geyser.GeyserBootstrap; import org.geysermc.geyser.GeyserBootstrap;
import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserImpl;
@ -51,7 +52,6 @@ import org.geysermc.geyser.platform.standalone.gui.GeyserStandaloneGUI;
import org.geysermc.geyser.text.GeyserLocale; import org.geysermc.geyser.text.GeyserLocale;
import org.geysermc.geyser.util.FileUtils; import org.geysermc.geyser.util.FileUtils;
import org.geysermc.geyser.util.LoopbackUtil; import org.geysermc.geyser.util.LoopbackUtil;
import org.jetbrains.annotations.NotNull;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -292,7 +292,7 @@ public class GeyserStandaloneBootstrap implements GeyserBootstrap {
return new GeyserStandaloneDumpInfo(this); return new GeyserStandaloneDumpInfo(this);
} }
@NotNull @NonNull
@Override @Override
public String getServerBindAddress() { public String getServerBindAddress() {
throw new IllegalStateException(); throw new IllegalStateException();
@ -325,7 +325,7 @@ public class GeyserStandaloneBootstrap implements GeyserBootstrap {
// Get the ignored properties // Get the ignored properties
Set<String> ignoredProperties = OBJECT_MAPPER.getSerializationConfig().getAnnotationIntrospector() Set<String> ignoredProperties = OBJECT_MAPPER.getSerializationConfig().getAnnotationIntrospector()
.findPropertyIgnorals(beanDescription.getClassInfo()).getIgnored(); .findPropertyIgnoralByName(OBJECT_MAPPER.getSerializationConfig() ,beanDescription.getClassInfo()).getIgnored();
// Filter properties removing the ignored ones // Filter properties removing the ignored ones
return properties.stream() return properties.stream()
@ -340,7 +340,7 @@ public class GeyserStandaloneBootstrap implements GeyserBootstrap {
* @param parentObject The object to alter * @param parentObject The object to alter
* @param value The new value of the property * @param value The new value of the property
*/ */
@SuppressWarnings("unchecked") // Required for enum usage @SuppressWarnings({"unchecked", "rawtypes"}) // Required for enum usage
private static void setConfigOption(BeanPropertyDefinition property, Object parentObject, Object value) { private static void setConfigOption(BeanPropertyDefinition property, Object parentObject, Object value) {
Object parsedValue = value; Object parsedValue = value;

View File

@ -28,11 +28,16 @@ package org.geysermc.geyser.platform.standalone.gui;
import javax.swing.*; import javax.swing.*;
import javax.swing.text.*; import javax.swing.text.*;
import java.awt.*; import java.awt.*;
import java.io.Serial;
/** /**
* This class was based on this code: https://stackoverflow.com/a/6899478/5299903 * This class was based on this <a href="https://stackoverflow.com/a/6899478/5299903">code</a>
*/ */
public class ColorPane extends JTextPane { public class ColorPane extends JTextPane {
@Serial
private static final long serialVersionUID = 1L;
private static Color colorCurrent = ANSIColor.RESET.getColor(); private static Color colorCurrent = ANSIColor.RESET.getColor();
private String remaining = ""; private String remaining = "";
@ -62,7 +67,7 @@ public class ColorPane extends JTextPane {
int aPos = 0; // current char position in addString int aPos = 0; // current char position in addString
int aIndex; // index of next Escape sequence int aIndex; // index of next Escape sequence
int mIndex; // index of "m" terminating Escape sequence int mIndex; // index of "m" terminating Escape sequence
String tmpString = ""; String tmpString;
boolean stillSearching = true; // true until no more Escape sequences boolean stillSearching = true; // true until no more Escape sequences
String addString = remaining + s; String addString = remaining + s;
remaining = ""; remaining = "";

View File

@ -25,6 +25,7 @@
package org.geysermc.geyser.platform.standalone.gui; package org.geysermc.geyser.platform.standalone.gui;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.GeyserLogger;
import org.geysermc.geyser.command.GeyserCommandManager; import org.geysermc.geyser.command.GeyserCommandManager;
@ -64,7 +65,6 @@ public class GeyserStandaloneGUI {
private final List<Integer> ramValues = new ArrayList<>(); private final List<Integer> ramValues = new ArrayList<>();
private final DefaultTableModel playerTableModel = new DefaultTableModel(); private final DefaultTableModel playerTableModel = new DefaultTableModel();
private final JTable playerTable = new JTable(playerTableModel);
/** /**
* Create and show the Geyser-Standalone GUI * Create and show the Geyser-Standalone GUI
@ -158,6 +158,7 @@ public class GeyserStandaloneGUI {
playerTableModel.addColumn(GeyserLocale.getLocaleStringLog("geyser.gui.table.ip")); playerTableModel.addColumn(GeyserLocale.getLocaleStringLog("geyser.gui.table.ip"));
playerTableModel.addColumn(GeyserLocale.getLocaleStringLog("geyser.gui.table.username")); playerTableModel.addColumn(GeyserLocale.getLocaleStringLog("geyser.gui.table.username"));
JTable playerTable = new JTable(playerTableModel);
JScrollPane playerScrollPane = new JScrollPane(playerTable); JScrollPane playerScrollPane = new JScrollPane(playerTable);
rightContentPane.add(playerScrollPane); rightContentPane.add(playerScrollPane);
@ -253,12 +254,12 @@ public class GeyserStandaloneGUI {
} }
@Override @Override
public void write(byte[] b, int off, int len) { public void write(byte @NonNull [] b, int off, int len) {
appendConsole(new String(b, off, len)); appendConsole(new String(b, off, len));
} }
@Override @Override
public void write(byte[] b) { public void write(byte @NonNull[] b) {
write(b, 0, b.length); write(b, 0, b.length);
} }
}; };

View File

@ -29,15 +29,20 @@ import lombok.Setter;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.io.Serial;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
/** /**
* This has been modified to fit Geyser more but is based on * This has been modified to fit Geyser more but is based on
* https://gist.github.com/roooodcastro/6325153#gistcomment-3107524 * <a href="https://gist.github.com/roooodcastro/6325153#gistcomment-3107524">this Github gist</a>
*/ */
public final class GraphPanel extends JPanel { public final class GraphPanel extends JPanel {
@Serial
private static final long serialVersionUID = 1L;
private final static int padding = 10; private final static int padding = 10;
private final static int labelPadding = 25; private final static int labelPadding = 25;
private final static int pointWidth = 4; private final static int pointWidth = 4;
@ -103,7 +108,7 @@ public final class GraphPanel extends JPanel {
g.drawLine(padding + labelPadding + 1 + pointWidth, y, width - padding, y); g.drawLine(padding + labelPadding + 1 + pointWidth, y, width - padding, y);
g.setColor(Color.BLACK); g.setColor(Color.BLACK);
final int tickValue = (int) (minScore + ((scoreRange * i) / numberYDivisions)); final int tickValue = minScore + ((scoreRange * i) / numberYDivisions);
final String yLabel = tickValue + ""; final String yLabel = tickValue + "";
final int labelWidth = fontMetrics.stringWidth(yLabel); final int labelWidth = fontMetrics.stringWidth(yLabel);
g.drawString(yLabel, x1 - labelWidth - 5, y + (fontHeight / 2) - 3); g.drawString(yLabel, x1 - labelWidth - 5, y + (fontHeight / 2) - 3);

View File

@ -29,6 +29,7 @@ import com.velocitypowered.api.proxy.ProxyServer;
import io.netty.bootstrap.ServerBootstrap; import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.*; import io.netty.channel.*;
import io.netty.channel.local.LocalAddress; import io.netty.channel.local.LocalAddress;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.geyser.GeyserBootstrap; import org.geysermc.geyser.GeyserBootstrap;
import org.geysermc.geyser.network.netty.GeyserInjector; import org.geysermc.geyser.network.netty.GeyserInjector;
import org.geysermc.geyser.network.netty.LocalServerChannelWrapper; import org.geysermc.geyser.network.netty.LocalServerChannelWrapper;
@ -76,7 +77,7 @@ public class GeyserVelocityInjector extends GeyserInjector {
.channel(LocalServerChannelWrapper.class) .channel(LocalServerChannelWrapper.class)
.childHandler(new ChannelInitializer<>() { .childHandler(new ChannelInitializer<>() {
@Override @Override
protected void initChannel(Channel ch) throws Exception { protected void initChannel(@NonNull Channel ch) throws Exception {
initChannel.invoke(channelInitializer, ch); initChannel.invoke(channelInitializer, ch);
if (bootstrap.getGeyserConfig().isDisableCompression() && GeyserVelocityCompressionDisabler.ENABLED) { if (bootstrap.getGeyserConfig().isDisableCompression() && GeyserVelocityCompressionDisabler.ENABLED) {

View File

@ -36,11 +36,13 @@ import com.velocitypowered.api.plugin.Plugin;
import com.velocitypowered.api.proxy.ProxyServer; import com.velocitypowered.api.proxy.ProxyServer;
import lombok.Getter; import lombok.Getter;
import net.kyori.adventure.util.Codec; import net.kyori.adventure.util.Codec;
import org.geysermc.geyser.api.util.PlatformType; import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.geyser.GeyserBootstrap; import org.geysermc.geyser.GeyserBootstrap;
import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.api.command.Command; import org.geysermc.geyser.api.command.Command;
import org.geysermc.geyser.api.extension.Extension; import org.geysermc.geyser.api.extension.Extension;
import org.geysermc.geyser.api.util.PlatformType;
import org.geysermc.geyser.command.GeyserCommandManager; import org.geysermc.geyser.command.GeyserCommandManager;
import org.geysermc.geyser.configuration.GeyserConfiguration; import org.geysermc.geyser.configuration.GeyserConfiguration;
import org.geysermc.geyser.dump.BootstrapDumpInfo; import org.geysermc.geyser.dump.BootstrapDumpInfo;
@ -49,8 +51,6 @@ import org.geysermc.geyser.ping.IGeyserPingPassthrough;
import org.geysermc.geyser.platform.velocity.command.GeyserVelocityCommandExecutor; import org.geysermc.geyser.platform.velocity.command.GeyserVelocityCommandExecutor;
import org.geysermc.geyser.text.GeyserLocale; import org.geysermc.geyser.text.GeyserLocale;
import org.geysermc.geyser.util.FileUtils; import org.geysermc.geyser.util.FileUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger; import org.slf4j.Logger;
import java.io.File; import java.io.File;
@ -222,7 +222,7 @@ public class GeyserVelocityPlugin implements GeyserBootstrap {
return this.geyserInjector.getServerSocketAddress(); return this.geyserInjector.getServerSocketAddress();
} }
@NotNull @NonNull
@Override @Override
public String getServerBindAddress() { public String getServerBindAddress() {
return proxyServer.getBoundAddress().getHostString(); return proxyServer.getBoundAddress().getHostString();

View File

@ -30,6 +30,7 @@ import com.velocitypowered.api.proxy.ConsoleCommandSource;
import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.Player;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.geyser.command.GeyserCommandSource; import org.geysermc.geyser.command.GeyserCommandSource;
import org.geysermc.geyser.text.GeyserLocale; import org.geysermc.geyser.text.GeyserLocale;
@ -56,7 +57,7 @@ public class VelocityCommandSource implements GeyserCommandSource {
} }
@Override @Override
public void sendMessage(String message) { public void sendMessage(@NonNull String message) {
handle.sendMessage(LegacyComponentSerializer.legacy('§').deserialize(message)); handle.sendMessage(LegacyComponentSerializer.legacy('§').deserialize(message));
} }

View File

@ -32,7 +32,7 @@ import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom; import java.security.SecureRandom;
public final class AesKeyProducer implements KeyProducer { public final class AesKeyProducer implements KeyProducer {
public static int KEY_SIZE = 128; public static final int KEY_SIZE = 128;
@Override @Override
public SecretKey produce() { public SecretKey produce() {

View File

@ -25,6 +25,7 @@
package org.geysermc.floodgate.crypto; package org.geysermc.floodgate.crypto;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.floodgate.util.InvalidFormatException; import org.geysermc.floodgate.util.InvalidFormatException;
import java.security.Key; import java.security.Key;
@ -97,7 +98,8 @@ public interface FloodgateCipher {
* @return the decrypted data in a UTF-8 String * @return the decrypted data in a UTF-8 String
* @throws Exception when the decrypting failed * @throws Exception when the decrypting failed
*/ */
default String decryptToString(byte[] data) throws Exception { @SuppressWarnings("unused")
default @Nullable String decryptToString(byte[] data) throws Exception {
byte[] decrypted = decrypt(data); byte[] decrypted = decrypt(data);
if (decrypted == null) { if (decrypted == null) {
return null; return null;
@ -113,6 +115,7 @@ public interface FloodgateCipher {
* @return the decrypted data in a byte[] * @return the decrypted data in a byte[]
* @throws Exception when the decrypting failed * @throws Exception when the decrypting failed
*/ */
@SuppressWarnings("unused")
default byte[] decryptFromString(String data) throws Exception { default byte[] decryptFromString(String data) throws Exception {
return decrypt(data.getBytes(UTF_8)); return decrypt(data.getBytes(UTF_8));
} }

View File

@ -31,7 +31,7 @@ import java.nio.file.Path;
import java.security.Key; import java.security.Key;
public interface KeyProducer { public interface KeyProducer {
Key produce(); @SuppressWarnings("unused") Key produce();
Key produceFrom(byte[] keyFileData); Key produceFrom(byte[] keyFileData);
default Key produceFrom(Path keyFileLocation) throws IOException { default Key produceFrom(Path keyFileLocation) throws IOException {

View File

@ -109,6 +109,7 @@ public final class NewsItem {
return (T) data; return (T) data;
} }
@SuppressWarnings("unused")
public String getRawMessage() { public String getRawMessage() {
return message; return message;
} }

View File

@ -25,6 +25,8 @@
package org.geysermc.floodgate.news; package org.geysermc.floodgate.news;
import org.checkerframework.checker.nullness.qual.Nullable;
public enum NewsItemAction { public enum NewsItemAction {
ON_SERVER_STARTED, ON_SERVER_STARTED,
ON_OPERATOR_JOIN, ON_OPERATOR_JOIN,
@ -33,7 +35,7 @@ public enum NewsItemAction {
private static final NewsItemAction[] VALUES = values(); private static final NewsItemAction[] VALUES = values();
public static NewsItemAction getByName(String actionName) { public static @Nullable NewsItemAction getByName(String actionName) {
for (NewsItemAction type : VALUES) { for (NewsItemAction type : VALUES) {
if (type.name().equalsIgnoreCase(actionName)) { if (type.name().equalsIgnoreCase(actionName)) {
return type; return type;

View File

@ -26,6 +26,7 @@
package org.geysermc.floodgate.news; package org.geysermc.floodgate.news;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import org.checkerframework.checker.nullness.qual.Nullable;
// {} is used for things that have to be filled in by the server, // {} is used for things that have to be filled in by the server,
// {@} is for things that have to be filled in by us // {@} is for things that have to be filled in by us
@ -49,7 +50,7 @@ public enum NewsItemMessage {
this.messageSplitted = messageFormat.split(" "); this.messageSplitted = messageFormat.split(" ");
} }
public static NewsItemMessage getById(int id) { public static @Nullable NewsItemMessage getById(int id) {
return VALUES.length > id ? VALUES[id] : null; return VALUES.length > id ? VALUES[id] : null;
} }

View File

@ -26,6 +26,7 @@
package org.geysermc.floodgate.news; package org.geysermc.floodgate.news;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.floodgate.news.data.*; import org.geysermc.floodgate.news.data.*;
import java.util.function.Function; import java.util.function.Function;
@ -44,7 +45,7 @@ public enum NewsType {
this.readFunction = readFunction; this.readFunction = readFunction;
} }
public static NewsType getByName(String newsType) { public static @Nullable NewsType getByName(String newsType) {
for (NewsType type : VALUES) { for (NewsType type : VALUES) {
if (type.name().equalsIgnoreCase(newsType)) { if (type.name().equalsIgnoreCase(newsType)) {
return type; return type;

View File

@ -56,6 +56,7 @@ public final class BuildSpecificData implements ItemData {
(allAffected || buildId > affectedGreaterThan && buildId < affectedLessThan); (allAffected || buildId > affectedGreaterThan && buildId < affectedLessThan);
} }
@SuppressWarnings("unused")
public String getBranch() { public String getBranch() {
return branch; return branch;
} }

View File

@ -51,6 +51,7 @@ public final class ConfigSpecificData implements ItemData {
return configSpecificData; return configSpecificData;
} }
@SuppressWarnings("unused")
public boolean isAffected(Map<String, String> config) { public boolean isAffected(Map<String, String> config) {
for (Map.Entry<String, Pattern> entry : affectedKeys.entrySet()) { for (Map.Entry<String, Pattern> entry : affectedKeys.entrySet()) {
if (config.containsKey(entry.getKey())) { if (config.containsKey(entry.getKey())) {

View File

@ -72,6 +72,7 @@ public final class BedrockData implements Cloneable {
false, subscribeId, verifyCode); false, subscribeId, verifyCode);
} }
@SuppressWarnings("unused")
public static BedrockData fromString(String data) { public static BedrockData fromString(String data) {
String[] split = data.split("\0"); String[] split = data.split("\0");
if (split.length != EXPECTED_LENGTH) { if (split.length != EXPECTED_LENGTH) {
@ -92,6 +93,7 @@ public final class BedrockData implements Cloneable {
dataLength); dataLength);
} }
@SuppressWarnings("unused")
public boolean hasPlayerLink() { public boolean hasPlayerLink() {
return linkedPlayer != null; return linkedPlayer != null;
} }

View File

@ -26,6 +26,9 @@
package org.geysermc.floodgate.util; package org.geysermc.floodgate.util;
public class InvalidFormatException extends Exception { public class InvalidFormatException extends Exception {
private static final long serialVersionUID = 1L;
public InvalidFormatException(String message) { public InvalidFormatException(String message) {
super(message); super(message);
} }

View File

@ -28,6 +28,7 @@ package org.geysermc.floodgate.util;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.Getter; import lombok.Getter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.UUID; import java.util.UUID;
@ -56,7 +57,7 @@ public final class LinkedPlayer implements Cloneable {
return new LinkedPlayer(javaUsername, javaUniqueId, bedrockId); return new LinkedPlayer(javaUsername, javaUniqueId, bedrockId);
} }
public static LinkedPlayer fromString(String data) { public static @Nullable LinkedPlayer fromString(String data) {
String[] split = data.split(";"); String[] split = data.split(";");
if (split.length != 3) { if (split.length != 3) {
return null; return null;

View File

@ -25,6 +25,8 @@
package org.geysermc.floodgate.util; package org.geysermc.floodgate.util;
import org.checkerframework.checker.nullness.qual.NonNull;
public enum UiProfile { public enum UiProfile {
CLASSIC, CLASSIC,
POCKET; POCKET;
@ -37,7 +39,7 @@ public enum UiProfile {
* @param id the UiProfile identifier * @param id the UiProfile identifier
* @return The UiProfile or {@link #CLASSIC} if the UiProfile wasn't found * @return The UiProfile or {@link #CLASSIC} if the UiProfile wasn't found
*/ */
public static UiProfile fromId(int id) { public static @NonNull UiProfile fromId(int id) {
return VALUES.length > id ? VALUES[id] : VALUES[0]; return VALUES.length > id ? VALUES[id] : VALUES[0];
} }
} }

View File

@ -25,6 +25,8 @@
package org.geysermc.floodgate.util; package org.geysermc.floodgate.util;
import org.checkerframework.checker.nullness.qual.Nullable;
public enum WebsocketEventType { public enum WebsocketEventType {
/** /**
* Sent once we successfully connected to the server * Sent once we successfully connected to the server
@ -81,7 +83,7 @@ public enum WebsocketEventType {
this.id = id; this.id = id;
} }
public static WebsocketEventType fromId(int id) { public static @Nullable WebsocketEventType fromId(int id) {
return VALUES.length > id ? VALUES[id] : null; return VALUES.length > id ? VALUES[id] : null;
} }

View File

@ -152,7 +152,7 @@ public interface GeyserBootstrap {
* @param resource Resource to get * @param resource Resource to get
* @return InputStream of the given resource * @return InputStream of the given resource
*/ */
default @NonNull InputStream getResource(String resource) { default @NonNull InputStream getResourceOrThrow(@NonNull String resource) {
InputStream stream = getResourceOrNull(resource); InputStream stream = getResourceOrNull(resource);
if (stream == null) { if (stream == null) {
throw new AssertionError("Unable to find resource: " + resource); throw new AssertionError("Unable to find resource: " + resource);

View File

@ -71,6 +71,7 @@ import org.geysermc.geyser.level.WorldManager;
import org.geysermc.geyser.network.netty.GeyserServer; import org.geysermc.geyser.network.netty.GeyserServer;
import org.geysermc.geyser.registry.BlockRegistries; import org.geysermc.geyser.registry.BlockRegistries;
import org.geysermc.geyser.registry.Registries; import org.geysermc.geyser.registry.Registries;
import org.geysermc.geyser.registry.provider.ProviderSupplier;
import org.geysermc.geyser.scoreboard.ScoreboardUpdater; import org.geysermc.geyser.scoreboard.ScoreboardUpdater;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.session.PendingMicrosoftAuthentication; import org.geysermc.geyser.session.PendingMicrosoftAuthentication;
@ -622,7 +623,7 @@ public class GeyserImpl implements GeyserApi {
*/ */
public boolean isProductionEnvironment() { public boolean isProductionEnvironment() {
// First is if Blossom runs, second is if Blossom doesn't run // First is if Blossom runs, second is if Blossom doesn't run
// noinspection ConstantConditions - changes in production //noinspection ConstantConditions,MismatchedStringCase - changes in production
return !("git-local/dev-0000000".equals(GeyserImpl.GIT_VERSION) || "${gitVersion}".equals(GeyserImpl.GIT_VERSION)); return !("git-local/dev-0000000".equals(GeyserImpl.GIT_VERSION) || "${gitVersion}".equals(GeyserImpl.GIT_VERSION));
} }
@ -638,8 +639,13 @@ public class GeyserImpl implements GeyserApi {
} }
@Override @Override
@SuppressWarnings("unchecked")
public <R extends T, T> @NonNull R provider(@NonNull Class<T> apiClass, @Nullable Object... args) { public <R extends T, T> @NonNull R provider(@NonNull Class<T> apiClass, @Nullable Object... args) {
return (R) Registries.PROVIDERS.get(apiClass).create(args); ProviderSupplier provider = Registries.PROVIDERS.get(apiClass);
if (provider == null) {
throw new IllegalArgumentException("No provider found for " + apiClass);
}
return (R) provider.create(args);
} }
@Override @Override

View File

@ -26,9 +26,10 @@
package org.geysermc.geyser; package org.geysermc.geyser;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.geyser.command.GeyserCommandSource; import org.geysermc.geyser.command.GeyserCommandSource;
import javax.annotation.Nullable;
public interface GeyserLogger extends GeyserCommandSource { public interface GeyserLogger extends GeyserCommandSource {
@ -119,7 +120,7 @@ public interface GeyserLogger extends GeyserCommandSource {
} }
@Override @Override
default void sendMessage(String message) { default void sendMessage(@NonNull String message) {
info(message); info(message);
} }

View File

@ -30,6 +30,7 @@ import java.io.InputStream;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.Locale; import java.util.Locale;
import java.util.Objects;
import java.util.Scanner; import java.util.Scanner;
public class GeyserMain { public class GeyserMain {
@ -61,8 +62,8 @@ public class GeyserMain {
helpStream = GeyserMain.class.getClassLoader().getResourceAsStream("languages/run-help/en_US.txt"); helpStream = GeyserMain.class.getClassLoader().getResourceAsStream("languages/run-help/en_US.txt");
} }
Scanner help = new Scanner(helpStream, StandardCharsets.UTF_8).useDelimiter("\\Z"); Scanner help = new Scanner(Objects.requireNonNull(helpStream), StandardCharsets.UTF_8).useDelimiter("\\Z");
String line = ""; String line;
while (help.hasNext()) { while (help.hasNext()) {
line = help.next(); line = help.next();

View File

@ -29,10 +29,10 @@ import lombok.Getter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.geyser.api.command.Command; import org.geysermc.geyser.api.command.Command;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
import javax.annotation.Nullable;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -73,15 +73,6 @@ public abstract class GeyserCommand implements Command {
return Collections.emptyList(); return Collections.emptyList();
} }
/**
* Shortcut to {@link #subCommands()} ()}{@code .isEmpty()}.
*
* @return true if there are subcommand present for this command.
*/
public boolean hasSubCommands() {
return !this.subCommands().isEmpty();
}
public void setAliases(List<String> aliases) { public void setAliases(List<String> aliases) {
this.aliases = aliases; this.aliases = aliases;
} }

View File

@ -26,11 +26,11 @@
package org.geysermc.geyser.command; package org.geysermc.geyser.command;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.api.command.Command; import org.geysermc.geyser.api.command.Command;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
import javax.annotation.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;

View File

@ -29,6 +29,7 @@ import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import lombok.Getter; import lombok.Getter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.geyser.api.util.PlatformType; import org.geysermc.geyser.api.util.PlatformType;
import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.api.command.Command; import org.geysermc.geyser.api.command.Command;
@ -53,8 +54,6 @@ import org.geysermc.geyser.event.type.GeyserDefineCommandsEventImpl;
import org.geysermc.geyser.extension.command.GeyserExtensionCommand; import org.geysermc.geyser.extension.command.GeyserExtensionCommand;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.text.GeyserLocale; import org.geysermc.geyser.text.GeyserLocale;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
@ -136,12 +135,12 @@ public class GeyserCommandManager {
} }
} }
@NotNull @NonNull
public Map<String, Command> commands() { public Map<String, Command> commands() {
return Collections.unmodifiableMap(this.commands); return Collections.unmodifiableMap(this.commands);
} }
@NotNull @NonNull
public Map<Extension, Map<String, Command>> extensionCommands() { public Map<Extension, Map<String, Command>> extensionCommands() {
return Collections.unmodifiableMap(this.extensionCommands); return Collections.unmodifiableMap(this.extensionCommands);
} }

View File

@ -26,6 +26,7 @@
package org.geysermc.geyser.command.defaults; package org.geysermc.geyser.command.defaults;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.api.util.PlatformType; import org.geysermc.geyser.api.util.PlatformType;
import org.geysermc.geyser.command.GeyserCommand; import org.geysermc.geyser.command.GeyserCommand;
@ -34,7 +35,6 @@ import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.text.GeyserLocale; import org.geysermc.geyser.text.GeyserLocale;
import org.geysermc.geyser.util.LoopbackUtil; import org.geysermc.geyser.util.LoopbackUtil;
import org.geysermc.geyser.util.WebUtils; import org.geysermc.geyser.util.WebUtils;
import org.jetbrains.annotations.Nullable;
import java.util.Random; import java.util.Random;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;

View File

@ -98,7 +98,7 @@ public class DumpCommand extends GeyserCommand {
return; return;
} }
String uploadedDumpUrl = ""; String uploadedDumpUrl;
if (offlineDump) { if (offlineDump) {
sender.sendMessage(GeyserLocale.getPlayerLocaleString("geyser.commands.dump.writing", sender.locale())); sender.sendMessage(GeyserLocale.getPlayerLocaleString("geyser.commands.dump.writing", sender.locale()));

View File

@ -25,6 +25,7 @@
package org.geysermc.geyser.command.defaults; package org.geysermc.geyser.command.defaults;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.api.extension.Extension; import org.geysermc.geyser.api.extension.Extension;
import org.geysermc.geyser.command.GeyserCommand; import org.geysermc.geyser.command.GeyserCommand;
@ -32,7 +33,6 @@ import org.geysermc.geyser.command.GeyserCommandSource;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.text.ChatColor; import org.geysermc.geyser.text.ChatColor;
import org.geysermc.geyser.text.GeyserLocale; import org.geysermc.geyser.text.GeyserLocale;
import org.jetbrains.annotations.Nullable;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;

View File

@ -27,8 +27,8 @@ package org.geysermc.geyser.command.defaults;
import org.cloudburstmc.protocol.bedrock.codec.BedrockCodec; import org.cloudburstmc.protocol.bedrock.codec.BedrockCodec;
import org.geysermc.geyser.Constants; import org.geysermc.geyser.Constants;
import org.geysermc.geyser.api.util.PlatformType;
import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.api.util.PlatformType;
import org.geysermc.geyser.command.GeyserCommand; import org.geysermc.geyser.command.GeyserCommand;
import org.geysermc.geyser.command.GeyserCommandSource; import org.geysermc.geyser.command.GeyserCommandSource;
import org.geysermc.geyser.network.GameProtocol; import org.geysermc.geyser.network.GameProtocol;
@ -37,7 +37,6 @@ import org.geysermc.geyser.text.ChatColor;
import org.geysermc.geyser.text.GeyserLocale; import org.geysermc.geyser.text.GeyserLocale;
import org.geysermc.geyser.util.WebUtils; import org.geysermc.geyser.util.WebUtils;
import java.io.IOException;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.List; import java.util.List;
@ -77,7 +76,7 @@ public class VersionCommand extends GeyserCommand {
sender.sendMessage(GeyserLocale.getPlayerLocaleString("geyser.commands.version.checking", sender.locale())); sender.sendMessage(GeyserLocale.getPlayerLocaleString("geyser.commands.version.checking", sender.locale()));
try { try {
String buildXML = WebUtils.getBody("https://ci.opencollab.dev/job/GeyserMC/job/Geyser/job/" + String buildXML = WebUtils.getBody("https://ci.opencollab.dev/job/GeyserMC/job/Geyser/job/" +
URLEncoder.encode(GeyserImpl.BRANCH, StandardCharsets.UTF_8.toString()) + "/lastSuccessfulBuild/api/xml?xpath=//buildNumber"); URLEncoder.encode(GeyserImpl.BRANCH, StandardCharsets.UTF_8) + "/lastSuccessfulBuild/api/xml?xpath=//buildNumber");
if (buildXML.startsWith("<buildNumber>")) { if (buildXML.startsWith("<buildNumber>")) {
int latestBuildNum = Integer.parseInt(buildXML.replaceAll("<(\\\\)?(/)?buildNumber>", "").trim()); int latestBuildNum = Integer.parseInt(buildXML.replaceAll("<(\\\\)?(/)?buildNumber>", "").trim());
int buildNum = this.geyser.buildNumber(); int buildNum = this.geyser.buildNumber();
@ -90,7 +89,7 @@ public class VersionCommand extends GeyserCommand {
} else { } else {
throw new AssertionError("buildNumber missing"); throw new AssertionError("buildNumber missing");
} }
} catch (IOException e) { } catch (Exception e) {
GeyserImpl.getInstance().getLogger().error(GeyserLocale.getLocaleStringLog("geyser.commands.version.failed"), e); GeyserImpl.getInstance().getLogger().error(GeyserLocale.getLocaleStringLog("geyser.commands.version.failed"), e);
sender.sendMessage(ChatColor.RED + GeyserLocale.getPlayerLocaleString("geyser.commands.version.failed", sender.locale())); sender.sendMessage(ChatColor.RED + GeyserLocale.getPlayerLocaleString("geyser.commands.version.failed", sender.locale()));
} }

View File

@ -52,6 +52,7 @@ public interface GeyserConfiguration {
List<String> getSavedUserLogins(); List<String> getSavedUserLogins();
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
boolean isCommandSuggestions(); boolean isCommandSuggestions();
@JsonIgnore @JsonIgnore
@ -93,6 +94,7 @@ public interface GeyserConfiguration {
boolean isForceResourcePacks(); boolean isForceResourcePacks();
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
boolean isXboxAchievementsEnabled(); boolean isXboxAchievementsEnabled();
int getCacheImages(); int getCacheImages();

View File

@ -34,6 +34,7 @@ import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.api.network.AuthType; import org.geysermc.geyser.api.network.AuthType;
import org.geysermc.geyser.network.CIDRMatcher; import org.geysermc.geyser.network.CIDRMatcher;
@ -158,7 +159,7 @@ public abstract class GeyserJacksonConfiguration implements GeyserConfiguration
private String address = "0.0.0.0"; private String address = "0.0.0.0";
@Override @Override
public String address() { public @NonNull String address() {
return address; return address;
} }
@ -260,7 +261,7 @@ public abstract class GeyserJacksonConfiguration implements GeyserConfiguration
private AuthType authType = AuthType.ONLINE; private AuthType authType = AuthType.ONLINE;
@Override @Override
public AuthType authType() { public @NonNull AuthType authType() {
return authType; return authType;
} }

View File

@ -33,7 +33,6 @@ import com.google.common.io.ByteSource;
import com.google.common.io.Files; import com.google.common.io.Files;
import it.unimi.dsi.fastutil.objects.Object2IntMap; import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import org.cloudburstmc.protocol.bedrock.codec.BedrockCodec; import org.cloudburstmc.protocol.bedrock.codec.BedrockCodec;
import org.geysermc.floodgate.util.DeviceOs; import org.geysermc.floodgate.util.DeviceOs;
@ -106,8 +105,8 @@ public class DumpInfo {
// https://stackoverflow.com/questions/304268/getting-a-files-md5-checksum-in-java // https://stackoverflow.com/questions/304268/getting-a-files-md5-checksum-in-java
File file = new File(DumpInfo.class.getProtectionDomain().getCodeSource().getLocation().toURI()); File file = new File(DumpInfo.class.getProtectionDomain().getCodeSource().getLocation().toURI());
ByteSource byteSource = Files.asByteSource(file); ByteSource byteSource = Files.asByteSource(file);
// Jenkins uses MD5 for its hash // Jenkins uses MD5 for its hash - TODO remove
//noinspection UnstableApiUsage //noinspection UnstableApiUsage,deprecation
md5Hash = byteSource.hash(Hashing.md5()).toString(); md5Hash = byteSource.hash(Hashing.md5()).toString();
//noinspection UnstableApiUsage //noinspection UnstableApiUsage
sha256Hash = byteSource.hash(Hashing.sha256()).toString(); sha256Hash = byteSource.hash(Hashing.sha256()).toString();
@ -118,7 +117,7 @@ public class DumpInfo {
} }
this.hashInfo = new HashInfo(md5Hash, sha256Hash); this.hashInfo = new HashInfo(md5Hash, sha256Hash);
this.ramInfo = new DumpInfo.RamInfo(); this.ramInfo = new RamInfo();
if (addLog) { if (addLog) {
this.logsInfo = new LogsInfo(); this.logsInfo = new LogsInfo();
@ -202,7 +201,7 @@ public class DumpInfo {
private boolean checkDockerBasic() { private boolean checkDockerBasic() {
try { try {
String OS = System.getProperty("os.name").toLowerCase(); String OS = System.getProperty("os.name").toLowerCase();
if (OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") > 0) { if (OS.contains("nix") || OS.contains("nux") || OS.indexOf("aix") > 0) {
String output = new String(java.nio.file.Files.readAllBytes(Paths.get("/proc/1/cgroup"))); String output = new String(java.nio.file.Files.readAllBytes(Paths.get("/proc/1/cgroup")));
if (output.contains("docker")) { if (output.contains("docker")) {
@ -259,60 +258,30 @@ public class DumpInfo {
} }
} }
@AllArgsConstructor public record HashInfo(String md5Hash, String sha256Hash) {
@Getter
public static class HashInfo {
private final String md5Hash;
private final String sha256Hash;
} }
@Getter public record RamInfo(long free, long total, long max) {
public static class RamInfo { public RamInfo() {
private final long free; this(Runtime.getRuntime().freeMemory() / MEGABYTE,
private final long total; Runtime.getRuntime().totalMemory() / MEGABYTE,
private final long max; Runtime.getRuntime().maxMemory() / MEGABYTE);
RamInfo() {
this.free = Runtime.getRuntime().freeMemory() / MEGABYTE;
this.total = Runtime.getRuntime().totalMemory() / MEGABYTE;
this.max = Runtime.getRuntime().maxMemory() / MEGABYTE;
} }
} }
/** /**
* E.G. `-Xmx1024M` - all runtime JVM flags on this machine * E.G. `-Xmx1024M` - all runtime JVM flags on this machine
*/ */
@Getter public record FlagsInfo(List<String> flags) {
public static class FlagsInfo { public FlagsInfo() {
private final List<String> flags; this(ManagementFactory.getRuntimeMXBean().getInputArguments());
FlagsInfo() {
this.flags = ManagementFactory.getRuntimeMXBean().getInputArguments();
} }
} }
@Getter public record ExtensionInfo(boolean enabled, String name, String version, String apiVersion, String main, List<String> authors) {
@AllArgsConstructor
public static class ExtensionInfo {
public boolean enabled;
public String name;
public String version;
public String apiVersion;
public String main;
public List<String> authors;
} }
@Getter public record GitInfo(String buildNumber, @JsonProperty("git.commit.id.abbrev") String commitHashAbbrev, @JsonProperty("git.commit.id") String commitHash,
@AllArgsConstructor @JsonProperty("git.branch") String branchName, @JsonProperty("git.remote.origin.url") String originUrl) {
public static class GitInfo {
private final String buildNumber;
@JsonProperty("git.commit.id.abbrev")
private final String commitHashAbbrev;
@JsonProperty("git.commit.id")
private final String commitHash;
@JsonProperty("git.branch")
private final String branchName;
@JsonProperty("git.remote.origin.url")
private final String originUrl;
} }
} }

View File

@ -59,6 +59,7 @@ public record EntityDefinition<T extends Entity>(EntityFactory<T> factory, Entit
return new Builder<>(factory); return new Builder<>(factory);
} }
@SuppressWarnings("unchecked")
public <M> void translateMetadata(T entity, EntityMetadata<M, ? extends MetadataType<M>> metadata) { public <M> void translateMetadata(T entity, EntityMetadata<M, ? extends MetadataType<M>> metadata) {
EntityMetadataTranslator<? super T, M, EntityMetadata<M, ? extends MetadataType<M>>> translator = (EntityMetadataTranslator<? super T, M, EntityMetadata<M, ? extends MetadataType<M>>>) this.translators.get(metadata.getId()); EntityMetadataTranslator<? super T, M, EntityMetadata<M, ? extends MetadataType<M>>> translator = (EntityMetadataTranslator<? super T, M, EntityMetadata<M, ? extends MetadataType<M>>>) this.translators.get(metadata.getId());
if (translator == null) { if (translator == null) {

View File

@ -25,6 +25,7 @@
package org.geysermc.geyser.entity.attribute; package org.geysermc.geyser.entity.attribute;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.cloudburstmc.protocol.bedrock.data.AttributeData; import org.cloudburstmc.protocol.bedrock.data.AttributeData;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
@ -69,7 +70,7 @@ public enum GeyserAttributeType {
return getAttribute(value, maximum); return getAttribute(value, maximum);
} }
public AttributeData getAttribute(float value, float maximum) { public @Nullable AttributeData getAttribute(float value, float maximum) {
if (bedrockIdentifier == null) { if (bedrockIdentifier == null) {
return null; return null;
} }

View File

@ -34,7 +34,6 @@ import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag; import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
import org.geysermc.geyser.entity.EntityDefinition; import org.geysermc.geyser.entity.EntityDefinition;
import org.geysermc.geyser.registry.Registries; import org.geysermc.geyser.registry.Registries;
import org.geysermc.geyser.registry.type.ParticleMapping;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
import java.util.UUID; import java.util.UUID;

View File

@ -36,6 +36,7 @@ import lombok.AccessLevel;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.cloudburstmc.math.vector.Vector2f; import org.cloudburstmc.math.vector.Vector2f;
import org.cloudburstmc.math.vector.Vector3f; import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes; import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
@ -580,7 +581,7 @@ public class Entity implements GeyserEntity {
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <I extends Entity> I as(Class<I> entityClass) { public <I extends Entity> @Nullable I as(Class<I> entityClass) {
return entityClass.isInstance(this) ? (I) this : null; return entityClass.isInstance(this) ? (I) this : null;
} }
} }

View File

@ -38,6 +38,7 @@ import com.github.steveice10.opennbt.tag.builtin.StringTag;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.cloudburstmc.math.vector.Vector3f; import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.math.vector.Vector3i; import org.cloudburstmc.math.vector.Vector3i;
import org.cloudburstmc.protocol.bedrock.data.AttributeData; import org.cloudburstmc.protocol.bedrock.data.AttributeData;
@ -120,7 +121,7 @@ public class LivingEntity extends Entity {
session.sendUpstreamPacket(attributesPacket); session.sendUpstreamPacket(attributesPacket);
} }
public Vector3i setBedPosition(EntityMetadata<Optional<Vector3i>, ?> entityMetadata) { public @Nullable Vector3i setBedPosition(EntityMetadata<Optional<Vector3i>, ?> entityMetadata) {
Optional<Vector3i> optionalPos = entityMetadata.getValue(); Optional<Vector3i> optionalPos = entityMetadata.getValue();
if (optionalPos.isPresent()) { if (optionalPos.isPresent()) {
Vector3i bedPosition = optionalPos.get(); Vector3i bedPosition = optionalPos.get();

View File

@ -51,7 +51,6 @@ public class ThrowableEntity extends Entity implements Tickable {
/** /**
* Updates the position for the Bedrock client. * Updates the position for the Bedrock client.
*
* Java clients assume the next positions of moving items. Bedrock needs to be explicitly told positions * Java clients assume the next positions of moving items. Bedrock needs to be explicitly told positions
*/ */
@Override @Override

View File

@ -26,6 +26,7 @@
package org.geysermc.geyser.entity.type.living; package org.geysermc.geyser.entity.type.living;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.math.vector.Vector3f; import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag; import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
import org.geysermc.geyser.entity.EntityDefinition; import org.geysermc.geyser.entity.EntityDefinition;
@ -34,7 +35,6 @@ import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.EntityUtils; import org.geysermc.geyser.util.EntityUtils;
import org.geysermc.geyser.util.InteractionResult; import org.geysermc.geyser.util.InteractionResult;
import javax.annotation.Nonnull;
import java.util.UUID; import java.util.UUID;
public class AbstractFishEntity extends WaterEntity { public class AbstractFishEntity extends WaterEntity {
@ -48,9 +48,9 @@ public class AbstractFishEntity extends WaterEntity {
setFlag(EntityFlag.HAS_GRAVITY, false); setFlag(EntityFlag.HAS_GRAVITY, false);
} }
@Nonnull @NonNull
@Override @Override
protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) { protected InteractionResult mobInteract(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (EntityUtils.attemptToBucket(itemInHand)) { if (EntityUtils.attemptToBucket(itemInHand)) {
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;
} else { } else {

View File

@ -27,6 +27,7 @@ package org.geysermc.geyser.entity.type.living;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata; import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.math.vector.Vector3f; import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag; import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
import org.geysermc.geyser.entity.EntityDefinition; import org.geysermc.geyser.entity.EntityDefinition;
@ -36,7 +37,6 @@ import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.InteractionResult; import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.geyser.util.InteractiveTag; import org.geysermc.geyser.util.InteractiveTag;
import javax.annotation.Nonnull;
import java.util.UUID; import java.util.UUID;
public class AllayEntity extends MobEntity { public class AllayEntity extends MobEntity {
@ -54,9 +54,9 @@ public class AllayEntity extends MobEntity {
this.canDuplicate = entityMetadata.getPrimitiveValue(); this.canDuplicate = entityMetadata.getPrimitiveValue();
} }
@Nonnull @NonNull
@Override @Override
protected InteractiveTag testMobInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) { protected InteractiveTag testMobInteraction(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (this.canDuplicate && getFlag(EntityFlag.DANCING) && isDuplicationItem(itemInHand)) { if (this.canDuplicate && getFlag(EntityFlag.DANCING) && isDuplicationItem(itemInHand)) {
// Maybe better as another tag? // Maybe better as another tag?
return InteractiveTag.GIVE_ITEM_TO_ALLAY; return InteractiveTag.GIVE_ITEM_TO_ALLAY;
@ -70,9 +70,9 @@ public class AllayEntity extends MobEntity {
} }
} }
@Nonnull @NonNull
@Override @Override
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) { protected InteractionResult mobInteract(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (this.canDuplicate && getFlag(EntityFlag.DANCING) && isDuplicationItem(itemInHand)) { if (this.canDuplicate && getFlag(EntityFlag.DANCING) && isDuplicationItem(itemInHand)) {
//TOCHECK sound //TOCHECK sound
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;

View File

@ -70,7 +70,7 @@ public class ArmorStandEntity extends LivingEntity {
private boolean primaryEntity = true; private boolean primaryEntity = true;
/** /**
* Whether the entity's position must be updated to included the offset. * Whether the entity's position must be updated to included the offset.
* * <p>
* This should be true when the Java server marks the armor stand as invisible, but we shrink the entity * This should be true when the Java server marks the armor stand as invisible, but we shrink the entity
* to allow the nametag to appear. Basically: * to allow the nametag to appear. Basically:
* - Is visible: this is irrelevant (false) * - Is visible: this is irrelevant (false)
@ -207,7 +207,7 @@ public class ArmorStandEntity extends LivingEntity {
* @param negativeZToggle the flag to set true if the Z value of rotation is negative * @param negativeZToggle the flag to set true if the Z value of rotation is negative
* @param rotation the Java rotation value * @param rotation the Java rotation value
*/ */
private void onRotationUpdate(EntityDataType dataLeech, EntityFlag negativeXToggle, EntityFlag negativeYToggle, EntityFlag negativeZToggle, Vector3f rotation) { private void onRotationUpdate(EntityDataType<Integer> dataLeech, EntityFlag negativeXToggle, EntityFlag negativeYToggle, EntityFlag negativeZToggle, Vector3f rotation) {
// Indicate that rotation should be checked // Indicate that rotation should be checked
setFlag(EntityFlag.BRIBED, true); setFlag(EntityFlag.BRIBED, true);

View File

@ -26,6 +26,7 @@
package org.geysermc.geyser.entity.type.living; package org.geysermc.geyser.entity.type.living;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.math.vector.Vector3f; import org.cloudburstmc.math.vector.Vector3f;
import org.geysermc.geyser.entity.EntityDefinition; import org.geysermc.geyser.entity.EntityDefinition;
import org.geysermc.geyser.inventory.GeyserItemStack; import org.geysermc.geyser.inventory.GeyserItemStack;
@ -33,7 +34,6 @@ import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.InteractionResult; import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.geyser.util.InteractiveTag; import org.geysermc.geyser.util.InteractiveTag;
import javax.annotation.Nonnull;
import java.util.UUID; import java.util.UUID;
public class DolphinEntity extends WaterEntity { public class DolphinEntity extends WaterEntity {
@ -46,18 +46,18 @@ public class DolphinEntity extends WaterEntity {
return true; return true;
} }
@Nonnull @NonNull
@Override @Override
protected InteractiveTag testMobInteraction(Hand hand, @Nonnull GeyserItemStack itemInHand) { protected InteractiveTag testMobInteraction(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (!itemInHand.isEmpty() && session.getTagCache().isFish(itemInHand)) { if (!itemInHand.isEmpty() && session.getTagCache().isFish(itemInHand)) {
return InteractiveTag.FEED; return InteractiveTag.FEED;
} }
return super.testMobInteraction(hand, itemInHand); return super.testMobInteraction(hand, itemInHand);
} }
@Nonnull @NonNull
@Override @Override
protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) { protected InteractionResult mobInteract(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (!itemInHand.isEmpty() && session.getTagCache().isFish(itemInHand)) { if (!itemInHand.isEmpty() && session.getTagCache().isFish(itemInHand)) {
// Feed // Feed
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;

View File

@ -26,6 +26,7 @@
package org.geysermc.geyser.entity.type.living; package org.geysermc.geyser.entity.type.living;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.math.vector.Vector3f; import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes; import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag; import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
@ -35,7 +36,6 @@ import org.geysermc.geyser.item.Items;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.InteractionResult; import org.geysermc.geyser.util.InteractionResult;
import javax.annotation.Nonnull;
import java.util.UUID; import java.util.UUID;
public class IronGolemEntity extends GolemEntity { public class IronGolemEntity extends GolemEntity {
@ -51,9 +51,9 @@ public class IronGolemEntity extends GolemEntity {
maxHealth = 100f; maxHealth = 100f;
} }
@Nonnull @NonNull
@Override @Override
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) { protected InteractionResult mobInteract(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (itemInHand.asItem() == Items.IRON_INGOT) { if (itemInHand.asItem() == Items.IRON_INGOT) {
if (health < maxHealth) { if (health < maxHealth) {
// Healing the iron golem // Healing the iron golem

View File

@ -28,6 +28,7 @@ package org.geysermc.geyser.entity.type.living;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata; import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import lombok.Getter; import lombok.Getter;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.math.vector.Vector3f; import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes; import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag; import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
@ -40,7 +41,6 @@ import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.InteractionResult; import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.geyser.util.InteractiveTag; import org.geysermc.geyser.util.InteractiveTag;
import javax.annotation.Nonnull;
import java.util.UUID; import java.util.UUID;
public class MobEntity extends LivingEntity { public class MobEntity extends LivingEntity {
@ -133,13 +133,13 @@ public class MobEntity extends LivingEntity {
return InteractionResult.PASS; return InteractionResult.PASS;
} }
@Nonnull @NonNull
protected InteractiveTag testMobInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) { protected InteractiveTag testMobInteraction(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
return InteractiveTag.NONE; return InteractiveTag.NONE;
} }
@Nonnull @NonNull
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) { protected InteractionResult mobInteract(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
return InteractionResult.PASS; return InteractionResult.PASS;
} }

View File

@ -27,6 +27,7 @@ package org.geysermc.geyser.entity.type.living;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata; import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.math.vector.Vector3f; import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag; import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
import org.geysermc.geyser.entity.EntityDefinition; import org.geysermc.geyser.entity.EntityDefinition;
@ -36,7 +37,6 @@ import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.InteractionResult; import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.geyser.util.InteractiveTag; import org.geysermc.geyser.util.InteractiveTag;
import javax.annotation.Nonnull;
import java.util.UUID; import java.util.UUID;
public class SnowGolemEntity extends GolemEntity { public class SnowGolemEntity extends GolemEntity {
@ -51,9 +51,9 @@ public class SnowGolemEntity extends GolemEntity {
setFlag(EntityFlag.SHEARED, (xd & 0x10) != 0x10); setFlag(EntityFlag.SHEARED, (xd & 0x10) != 0x10);
} }
@Nonnull @NonNull
@Override @Override
protected InteractiveTag testMobInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) { protected InteractiveTag testMobInteraction(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (Items.SHEARS == itemInHand.asItem() && isAlive() && !getFlag(EntityFlag.SHEARED)) { if (Items.SHEARS == itemInHand.asItem() && isAlive() && !getFlag(EntityFlag.SHEARED)) {
// Shearing the snow golem // Shearing the snow golem
return InteractiveTag.SHEAR; return InteractiveTag.SHEAR;
@ -61,9 +61,9 @@ public class SnowGolemEntity extends GolemEntity {
return InteractiveTag.NONE; return InteractiveTag.NONE;
} }
@Nonnull @NonNull
@Override @Override
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) { protected InteractionResult mobInteract(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (Items.SHEARS == itemInHand.asItem() && isAlive() && !getFlag(EntityFlag.SHEARED)) { if (Items.SHEARS == itemInHand.asItem() && isAlive() && !getFlag(EntityFlag.SHEARED)) {
// Shearing the snow golem // Shearing the snow golem
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;

View File

@ -26,6 +26,7 @@
package org.geysermc.geyser.entity.type.living; package org.geysermc.geyser.entity.type.living;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.math.vector.Vector3f; import org.cloudburstmc.math.vector.Vector3f;
import org.geysermc.geyser.entity.EntityDefinition; import org.geysermc.geyser.entity.EntityDefinition;
import org.geysermc.geyser.inventory.GeyserItemStack; import org.geysermc.geyser.inventory.GeyserItemStack;
@ -34,7 +35,6 @@ import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.InteractionResult; import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.geyser.util.InteractiveTag; import org.geysermc.geyser.util.InteractiveTag;
import javax.annotation.Nonnull;
import java.util.UUID; import java.util.UUID;
public class TadpoleEntity extends AbstractFishEntity { public class TadpoleEntity extends AbstractFishEntity {
@ -42,18 +42,18 @@ public class TadpoleEntity extends AbstractFishEntity {
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw); super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
} }
@Nonnull @NonNull
@Override @Override
protected InteractiveTag testMobInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) { protected InteractiveTag testMobInteraction(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (isFood(itemInHand)) { if (isFood(itemInHand)) {
return InteractiveTag.FEED; return InteractiveTag.FEED;
} }
return super.testMobInteraction(hand, itemInHand); return super.testMobInteraction(hand, itemInHand);
} }
@Nonnull @NonNull
@Override @Override
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) { protected InteractionResult mobInteract(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (isFood(itemInHand)) { if (isFood(itemInHand)) {
//TODO particles //TODO particles
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;

View File

@ -26,6 +26,7 @@
package org.geysermc.geyser.entity.type.living.animal; package org.geysermc.geyser.entity.type.living.animal;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.math.vector.Vector3f; import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityEventType; import org.cloudburstmc.protocol.bedrock.data.entity.EntityEventType;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag; import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
@ -38,7 +39,6 @@ import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.InteractionResult; import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.geyser.util.InteractiveTag; import org.geysermc.geyser.util.InteractiveTag;
import javax.annotation.Nonnull;
import java.util.UUID; import java.util.UUID;
public class AnimalEntity extends AgeableEntity { public class AnimalEntity extends AgeableEntity {
@ -59,18 +59,18 @@ public class AnimalEntity extends AgeableEntity {
return item == Items.WHEAT; return item == Items.WHEAT;
} }
@Nonnull @NonNull
@Override @Override
protected InteractiveTag testMobInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) { protected InteractiveTag testMobInteraction(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (canEat(itemInHand)) { if (canEat(itemInHand)) {
return InteractiveTag.FEED; return InteractiveTag.FEED;
} }
return super.testMobInteraction(hand, itemInHand); return super.testMobInteraction(hand, itemInHand);
} }
@Nonnull @NonNull
@Override @Override
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) { protected InteractionResult mobInteract(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (canEat(itemInHand)) { if (canEat(itemInHand)) {
// FEED // FEED
if (getFlag(EntityFlag.BABY)) { if (getFlag(EntityFlag.BABY)) {

View File

@ -28,6 +28,7 @@ package org.geysermc.geyser.entity.type.living.animal;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata; import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata; import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.math.vector.Vector3f; import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes; import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag; import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
@ -38,7 +39,6 @@ import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.EntityUtils; import org.geysermc.geyser.util.EntityUtils;
import org.geysermc.geyser.util.InteractionResult; import org.geysermc.geyser.util.InteractionResult;
import javax.annotation.Nonnull;
import java.util.UUID; import java.util.UUID;
public class AxolotlEntity extends AnimalEntity { public class AxolotlEntity extends AnimalEntity {
@ -74,9 +74,9 @@ public class AxolotlEntity extends AnimalEntity {
return true; return true;
} }
@Nonnull @NonNull
@Override @Override
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) { protected InteractionResult mobInteract(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (EntityUtils.attemptToBucket(itemInHand)) { if (EntityUtils.attemptToBucket(itemInHand)) {
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;
} else { } else {

View File

@ -26,6 +26,7 @@
package org.geysermc.geyser.entity.type.living.animal; package org.geysermc.geyser.entity.type.living.animal;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.math.vector.Vector3f; import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.data.SoundEvent; import org.cloudburstmc.protocol.bedrock.data.SoundEvent;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag; import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
@ -36,7 +37,6 @@ import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.InteractionResult; import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.geyser.util.InteractiveTag; import org.geysermc.geyser.util.InteractiveTag;
import javax.annotation.Nonnull;
import java.util.UUID; import java.util.UUID;
public class CowEntity extends AnimalEntity { public class CowEntity extends AnimalEntity {
@ -44,9 +44,9 @@ public class CowEntity extends AnimalEntity {
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw); super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
} }
@Nonnull @NonNull
@Override @Override
protected InteractiveTag testMobInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) { protected InteractiveTag testMobInteraction(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (getFlag(EntityFlag.BABY) || itemInHand.asItem() != Items.BUCKET) { if (getFlag(EntityFlag.BABY) || itemInHand.asItem() != Items.BUCKET) {
return super.testMobInteraction(hand, itemInHand); return super.testMobInteraction(hand, itemInHand);
} }
@ -54,9 +54,9 @@ public class CowEntity extends AnimalEntity {
return InteractiveTag.MILK; return InteractiveTag.MILK;
} }
@Nonnull @NonNull
@Override @Override
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) { protected InteractionResult mobInteract(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (getFlag(EntityFlag.BABY) || itemInHand.asItem() != Items.BUCKET) { if (getFlag(EntityFlag.BABY) || itemInHand.asItem() != Items.BUCKET) {
return super.mobInteract(hand, itemInHand); return super.mobInteract(hand, itemInHand);
} }

View File

@ -28,6 +28,7 @@ package org.geysermc.geyser.entity.type.living.animal;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Pose; import com.github.steveice10.mc.protocol.data.game.entity.metadata.Pose;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata; import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.math.vector.Vector3f; import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.data.SoundEvent; import org.cloudburstmc.protocol.bedrock.data.SoundEvent;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes; import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
@ -38,7 +39,6 @@ import org.geysermc.geyser.item.Items;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.InteractionResult; import org.geysermc.geyser.util.InteractionResult;
import javax.annotation.Nonnull;
import java.util.UUID; import java.util.UUID;
public class GoatEntity extends AnimalEntity { public class GoatEntity extends AnimalEntity {
@ -70,9 +70,9 @@ public class GoatEntity extends AnimalEntity {
// TODO testMobInteraction? // TODO testMobInteraction?
@Nonnull @NonNull
@Override @Override
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) { protected InteractionResult mobInteract(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (!getFlag(EntityFlag.BABY) && itemInHand.asItem() == Items.BUCKET) { if (!getFlag(EntityFlag.BABY) && itemInHand.asItem() == Items.BUCKET) {
session.playSoundEvent(isScreamer ? SoundEvent.MILK_SCREAMER : SoundEvent.MILK, position); session.playSoundEvent(isScreamer ? SoundEvent.MILK_SCREAMER : SoundEvent.MILK, position);
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;

View File

@ -27,6 +27,7 @@ package org.geysermc.geyser.entity.type.living.animal;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ObjectEntityMetadata; import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ObjectEntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.math.vector.Vector3f; import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes; import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
import org.geysermc.geyser.entity.EntityDefinition; import org.geysermc.geyser.entity.EntityDefinition;
@ -37,7 +38,6 @@ import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.InteractionResult; import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.geyser.util.InteractiveTag; import org.geysermc.geyser.util.InteractiveTag;
import javax.annotation.Nonnull;
import java.util.UUID; import java.util.UUID;
public class MooshroomEntity extends AnimalEntity { public class MooshroomEntity extends AnimalEntity {
@ -52,9 +52,9 @@ public class MooshroomEntity extends AnimalEntity {
dirtyMetadata.put(EntityDataTypes.VARIANT, isBrown ? 1 : 0); dirtyMetadata.put(EntityDataTypes.VARIANT, isBrown ? 1 : 0);
} }
@Nonnull @NonNull
@Override @Override
protected InteractiveTag testMobInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) { protected InteractiveTag testMobInteraction(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (!isBaby()) { if (!isBaby()) {
if (itemInHand.asItem() == Items.BOWL) { if (itemInHand.asItem() == Items.BOWL) {
// Stew // Stew
@ -67,9 +67,9 @@ public class MooshroomEntity extends AnimalEntity {
return super.testMobInteraction(hand, itemInHand); return super.testMobInteraction(hand, itemInHand);
} }
@Nonnull @NonNull
@Override @Override
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) { protected InteractionResult mobInteract(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
boolean isBaby = isBaby(); boolean isBaby = isBaby();
if (!isBaby && itemInHand.asItem() == Items.BOWL) { if (!isBaby && itemInHand.asItem() == Items.BOWL) {
// Stew // Stew

View File

@ -26,6 +26,7 @@
package org.geysermc.geyser.entity.type.living.animal; package org.geysermc.geyser.entity.type.living.animal;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.math.vector.Vector3f; import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag; import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
import org.geysermc.geyser.entity.EntityDefinition; import org.geysermc.geyser.entity.EntityDefinition;
@ -36,7 +37,6 @@ import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.InteractionResult; import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.geyser.util.InteractiveTag; import org.geysermc.geyser.util.InteractiveTag;
import javax.annotation.Nonnull;
import java.util.UUID; import java.util.UUID;
public class OcelotEntity extends AnimalEntity { public class OcelotEntity extends AnimalEntity {
@ -50,9 +50,9 @@ public class OcelotEntity extends AnimalEntity {
return item == Items.COD || item == Items.SALMON; return item == Items.COD || item == Items.SALMON;
} }
@Nonnull @NonNull
@Override @Override
protected InteractiveTag testMobInteraction(Hand hand, @Nonnull GeyserItemStack itemInHand) { protected InteractiveTag testMobInteraction(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (!getFlag(EntityFlag.TRUSTING) && canEat(itemInHand) && session.getPlayerEntity().getPosition().distanceSquared(position) < 9f) { if (!getFlag(EntityFlag.TRUSTING) && canEat(itemInHand) && session.getPlayerEntity().getPosition().distanceSquared(position) < 9f) {
// Attempt to feed // Attempt to feed
return InteractiveTag.FEED; return InteractiveTag.FEED;
@ -61,9 +61,9 @@ public class OcelotEntity extends AnimalEntity {
} }
} }
@Nonnull @NonNull
@Override @Override
protected InteractionResult mobInteract(Hand hand, @Nonnull GeyserItemStack itemInHand) { protected InteractionResult mobInteract(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (!getFlag(EntityFlag.TRUSTING) && canEat(itemInHand) && session.getPlayerEntity().getPosition().distanceSquared(position) < 9f) { if (!getFlag(EntityFlag.TRUSTING) && canEat(itemInHand) && session.getPlayerEntity().getPosition().distanceSquared(position) < 9f) {
// Attempt to feed // Attempt to feed
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;

View File

@ -28,6 +28,8 @@ package org.geysermc.geyser.entity.type.living.animal;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata; import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata; import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.cloudburstmc.math.vector.Vector3f; import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes; import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityEventType; import org.cloudburstmc.protocol.bedrock.data.entity.EntityEventType;
@ -41,8 +43,6 @@ import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.InteractionResult; import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.geyser.util.InteractiveTag; import org.geysermc.geyser.util.InteractiveTag;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.UUID; import java.util.UUID;
public class PandaEntity extends AnimalEntity { public class PandaEntity extends AnimalEntity {
@ -93,18 +93,18 @@ public class PandaEntity extends AnimalEntity {
return item == Items.BAMBOO; return item == Items.BAMBOO;
} }
@Nonnull @NonNull
@Override @Override
protected InteractiveTag testMobInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) { protected InteractiveTag testMobInteraction(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (mainGene == Gene.WORRIED && session.isThunder()) { if (mainGene == Gene.WORRIED && session.isThunder()) {
return InteractiveTag.NONE; return InteractiveTag.NONE;
} }
return super.testMobInteraction(hand, itemInHand); return super.testMobInteraction(hand, itemInHand);
} }
@Nonnull @NonNull
@Override @Override
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) { protected InteractionResult mobInteract(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (mainGene == Gene.WORRIED && session.isThunder()) { if (mainGene == Gene.WORRIED && session.isThunder()) {
// Huh! // Huh!
return InteractionResult.PASS; return InteractionResult.PASS;

View File

@ -26,6 +26,7 @@
package org.geysermc.geyser.entity.type.living.animal; package org.geysermc.geyser.entity.type.living.animal;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.math.vector.Vector3f; import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag; import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
import org.geysermc.geyser.entity.EntityDefinition; import org.geysermc.geyser.entity.EntityDefinition;
@ -37,7 +38,6 @@ import org.geysermc.geyser.util.EntityUtils;
import org.geysermc.geyser.util.InteractionResult; import org.geysermc.geyser.util.InteractionResult;
import org.geysermc.geyser.util.InteractiveTag; import org.geysermc.geyser.util.InteractiveTag;
import javax.annotation.Nonnull;
import java.util.UUID; import java.util.UUID;
public class PigEntity extends AnimalEntity { public class PigEntity extends AnimalEntity {
@ -51,9 +51,9 @@ public class PigEntity extends AnimalEntity {
return item == Items.CARROT || item == Items.POTATO || item == Items.BEETROOT; return item == Items.CARROT || item == Items.POTATO || item == Items.BEETROOT;
} }
@Nonnull @NonNull
@Override @Override
protected InteractiveTag testMobInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) { protected InteractiveTag testMobInteraction(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (!canEat(itemInHand) && getFlag(EntityFlag.SADDLED) && passengers.isEmpty() && !session.isSneaking()) { if (!canEat(itemInHand) && getFlag(EntityFlag.SADDLED) && passengers.isEmpty() && !session.isSneaking()) {
// Mount // Mount
return InteractiveTag.MOUNT; return InteractiveTag.MOUNT;
@ -68,9 +68,9 @@ public class PigEntity extends AnimalEntity {
} }
} }
@Nonnull @NonNull
@Override @Override
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) { protected InteractionResult mobInteract(@NonNull Hand hand, @NonNull GeyserItemStack itemInHand) {
if (!canEat(itemInHand) && getFlag(EntityFlag.SADDLED) && passengers.isEmpty() && !session.isSneaking()) { if (!canEat(itemInHand) && getFlag(EntityFlag.SADDLED) && passengers.isEmpty() && !session.isSneaking()) {
// Mount // Mount
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;

Some files were not shown because too many files have changed in this diff Show More