Skip to content

Commit e77097b

Browse files
committed
Add @nonnull annotations and minor code cleanup in core and peripheral files.
1 parent 696b5dd commit e77097b

3 files changed

Lines changed: 7 additions & 10 deletions

File tree

common/src/main/java/me/alexdevs/classicPeripherals/core/StateSaverAndLoader.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import net.minecraft.server.MinecraftServer;
88
import net.minecraft.world.level.Level;
99
import net.minecraft.world.level.saveddata.SavedData;
10+
import org.jspecify.annotations.NonNull;
1011

1112
import java.util.Map;
1213
import java.util.Optional;
@@ -62,7 +63,7 @@ public static StateSaverAndLoader getServerState(MinecraftServer server) {
6263
}
6364

6465
@Override
65-
public CompoundTag save(CompoundTag nbt, HolderLookup.Provider registries) {
66+
public @NonNull CompoundTag save(@NonNull CompoundTag nbt, HolderLookup.@NonNull Provider registries) {
6667
var cardDataMap = new CompoundTag();
6768
for (var entry : data.entrySet()) {
6869
CompoundTag cardDataItem = new CompoundTag();
@@ -88,9 +89,4 @@ public void setData(UUID id, DataHolderHandler.ItemData data) {
8889
this.data.put(id, data);
8990
this.setDirty(true);
9091
}
91-
92-
public void removeData(UUID id) {
93-
this.data.remove(id);
94-
this.setDirty(true);
95-
}
9692
}

common/src/main/java/me/alexdevs/classicPeripherals/mixin/ItemMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public abstract class ItemMixin {
2323
@Inject(method = "interactLivingEntity", at = @At("HEAD"), cancellable = true)
2424
private void classicperipherals$pocketInteractPlayer(ItemStack stack, Player source, LivingEntity target, InteractionHand usedHand, CallbackInfoReturnable<InteractionResult> cir) {
2525
var self = (Item) (Object) this;
26-
if (!(self instanceof PocketComputerItem pocketItem)) {
26+
if (!(self instanceof PocketComputerItem)) {
2727
return;
2828
}
2929

common/src/main/java/me/alexdevs/classicPeripherals/peripherals/rfid/RfidScannerPeripheral.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import dan200.computercraft.api.peripheral.IComputerAccess;
88
import dan200.computercraft.api.peripheral.IPeripheral;
99
import net.minecraft.world.phys.Vec3;
10+
import org.jspecify.annotations.NonNull;
1011
import org.jspecify.annotations.Nullable;
1112

1213
import java.util.HashMap;
@@ -22,7 +23,7 @@ public RfidScannerPeripheral(RfidScannerBlockEntity rfidScanner) {
2223
}
2324

2425
@Override
25-
public String getType() {
26+
public @NonNull String getType() {
2627
return "rfid_scanner";
2728
}
2829

@@ -32,12 +33,12 @@ public boolean equals(@Nullable IPeripheral other) {
3233
}
3334

3435
@Override
35-
public void attach(IComputerAccess computer) {
36+
public void attach(@NonNull IComputerAccess computer) {
3637
computers.add(computer);
3738
}
3839

3940
@Override
40-
public void detach(IComputerAccess computer) {
41+
public void detach(@NonNull IComputerAccess computer) {
4142
computers.remove(computer);
4243
}
4344

0 commit comments

Comments
 (0)