3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-04 23:30:17 +01:00

Add protection for out-of-bounds inventory management

Dieser Commit ist enthalten in:
Camotoy 2021-03-08 18:13:26 -05:00
Ursprung ad4196f5a0
Commit ffae69471d
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 7EEFB66FE798081F

Datei anzeigen

@ -30,6 +30,7 @@ import com.nukkitx.math.vector.Vector3i;
import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;
import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.network.session.GeyserSession;
import java.util.Arrays;
@ -86,10 +87,18 @@ public class Inventory {
}
public GeyserItemStack getItem(int slot) {
if (slot > this.size) {
GeyserConnector.getInstance().getLogger().debug("Tried to get an item out of bounds! " + this.toString());
return GeyserItemStack.EMPTY;
}
return items[slot];
}
public void setItem(int slot, @NonNull GeyserItemStack newItem, GeyserSession session) {
if (slot > this.size) {
session.getConnector().getLogger().debug("Tried to set an item out of bounds! " + this.toString());
return;
}
GeyserItemStack oldItem = items[slot];
updateItemNetId(oldItem, newItem, session);
items[slot] = newItem;