Skip to content

Commit 4a6cf12

Browse files
authored
Fix some IDE warnings (#273)
* sort modifiers * fix private Object Mapper field not having generic info * suppress unchecked cast warnings * apply missing override annotations * fix accessoryType null being evil * annotation a JeiPlugin method with NotNull * apply String#isEmpty where relevant * use canonical forms of floats * suppress ClassCanBeRecord * apply pattern variable in simple places * apply pattern variable to remaining places * remove duplicate semicolon
1 parent 2de715d commit 4a6cf12

File tree

146 files changed

+382
-503
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+382
-503
lines changed

src/main/java/com/cleanroommc/groovyscript/GroovyScript.java

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -204,33 +204,27 @@ public static void onInput(InputEvent.KeyInputEvent event) {
204204
}
205205
}
206206

207-
@NotNull
208-
public static String getScriptPath() {
207+
public static @NotNull String getScriptPath() {
209208
return getScriptFile().getPath();
210209
}
211210

212-
@NotNull
213-
public static File getMinecraftHome() {
211+
public static @NotNull File getMinecraftHome() {
214212
return SandboxData.getMinecraftHome();
215213
}
216214

217-
@NotNull
218-
public static File getScriptFile() {
215+
public static @NotNull File getScriptFile() {
219216
return SandboxData.getScriptFile();
220217
}
221218

222-
@NotNull
223-
public static File getResourcesFile() {
219+
public static @NotNull File getResourcesFile() {
224220
return SandboxData.getResourcesFile();
225221
}
226222

227-
@NotNull
228-
public static File getRunConfigFile() {
223+
public static @NotNull File getRunConfigFile() {
229224
return SandboxData.getRunConfigFile();
230225
}
231226

232-
@NotNull
233-
public static GroovyScriptSandbox getSandbox() {
227+
public static @NotNull GroovyScriptSandbox getSandbox() {
234228
if (sandbox == null) {
235229
throw new IllegalStateException("GroovyScript is not yet loaded or failed to load!");
236230
}

src/main/java/com/cleanroommc/groovyscript/api/GroovyLog.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ public interface GroovyLog {
3939
/**
4040
* @return an instance of {@link GroovyLog}
4141
*/
42-
@NotNull
43-
static GroovyLog get() {
42+
static @NotNull GroovyLog get() {
4443
return GroovyLogImpl.LOG;
4544
}
4645

src/main/java/com/cleanroommc/groovyscript/api/IGroovyContainer.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ public interface IGroovyContainer {
4545
*
4646
* @return aliases
4747
*/
48-
@NotNull
49-
default Collection<String> getAliases() {
48+
default @NotNull Collection<String> getAliases() {
5049
return Collections.singletonList(getModId());
5150
}
5251

@@ -67,8 +66,7 @@ default Collection<String> getAliases() {
6766
* @return the override priority
6867
* @see Priority
6968
*/
70-
@NotNull
71-
default Priority getOverridePriority() {
69+
default @NotNull Priority getOverridePriority() {
7270
return Priority.NONE;
7371
}
7472

src/main/java/com/cleanroommc/groovyscript/api/IIngredient.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,8 @@ public boolean test(ItemStack stack) {
9898
return stack.isEmpty();
9999
}
100100

101-
@Nullable
102101
@Override
103-
public String getMark() {
102+
public @Nullable String getMark() {
104103
return null;
105104
}
106105

@@ -152,9 +151,8 @@ public boolean test(ItemStack stack) {
152151
return true;
153152
}
154153

155-
@Nullable
156154
@Override
157-
public String getMark() {
155+
public @Nullable String getMark() {
158156
return null;
159157
}
160158

src/main/java/com/cleanroommc/groovyscript/api/INBTResourceStack.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ default boolean hasNbt() {
2020
@Nullable
2121
NBTTagCompound getNbt();
2222

23-
@NotNull
24-
default NBTTagCompound getOrCreateNbt() {
23+
default @NotNull NBTTagCompound getOrCreateNbt() {
2524
NBTTagCompound nbt = getNbt();
2625
if (nbt == null) {
2726
nbt = new NBTTagCompound();
@@ -30,8 +29,7 @@ default NBTTagCompound getOrCreateNbt() {
3029
return nbt;
3130
}
3231

33-
@Nullable
34-
default NBTBase getSubTag(String key) {
32+
default @Nullable NBTBase getSubTag(String key) {
3533
NBTTagCompound nbt = getNbt();
3634
return nbt == null ? null : nbt.getTag(key);
3735
}

src/main/java/com/cleanroommc/groovyscript/api/Result.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ static <T> Result<T> some(@NotNull T value) {
3636
@NotNull
3737
T getValue();
3838

39+
@SuppressWarnings("ClassCanBeRecord")
3940
class Some<T> implements Result<T> {
4041

4142
private final T value;
@@ -60,6 +61,7 @@ public boolean hasError() {
6061
}
6162
}
6263

64+
@SuppressWarnings("ClassCanBeRecord")
6365
class Error<T> implements Result<T> {
6466

6567
private final String error;

src/main/java/com/cleanroommc/groovyscript/api/infocommand/InfoParserPackage.java

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,58 +23,48 @@ public class InfoParserPackage {
2323
/**
2424
* Server where the command is executed
2525
*/
26-
@NotNull
27-
private final MinecraftServer server;
26+
private final @NotNull MinecraftServer server;
2827
/**
2928
* Player who executes the command
3029
*/
31-
@NotNull
32-
private final EntityPlayer player;
30+
private final @NotNull EntityPlayer player;
3331
/**
3432
* Arguments of the command
3533
*/
36-
@NotNull
37-
private final List<String> args;
34+
private final @NotNull List<String> args;
3835
/**
3936
* A list of messages that will be sent to the player after this event.
4037
* Add or remove your messages here.
4138
*/
42-
@NotNull
43-
private final List<ITextComponent> messages;
39+
private final @NotNull List<ITextComponent> messages;
4440
/**
4541
* If pretty nbt is enabled
4642
*/
4743
private final boolean prettyNbt;
4844
/**
4945
* The held item or the item form of the block being looked at.
5046
*/
51-
@NotNull
52-
private ItemStack stack;
47+
private @NotNull ItemStack stack;
5348
/**
5449
* The entity the player is looking at
5550
*/
56-
@Nullable
57-
private Entity entity;
51+
private @Nullable Entity entity;
5852
/**
5953
* The block position the player is looking at
6054
*/
61-
@Nullable
62-
private BlockPos pos;
55+
private @Nullable BlockPos pos;
6356
/**
6457
* The block state of the held item or the block state the player is looking at
6558
*/
66-
@Nullable
67-
private IBlockState blockState;
59+
private @Nullable IBlockState blockState;
6860
/**
6961
* The block of the held item or the block the player is looking at
7062
*/
71-
@Nullable
72-
private Block block;
63+
private @Nullable Block block;
7364
/**
7465
* The tile entity the player is looking at
7566
*/
76-
@Nullable
77-
private TileEntity tileEntity;
67+
private @Nullable TileEntity tileEntity;
7868

7969
public InfoParserPackage(
8070
@NotNull MinecraftServer server,

src/main/java/com/cleanroommc/groovyscript/command/GSCommand.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,22 @@ public GSCommand() {
3434
addSubcommand(new SimpleCommand("log", (server, sender, args) -> postLogFiles(sender)));
3535

3636
addSubcommand(new SimpleCommand("reload", (server, sender, args) -> {
37-
if (sender instanceof EntityPlayerMP) {
37+
if (sender instanceof EntityPlayerMP player) {
3838
if (hasArgument(args, "--clean")) {
3939
GroovyLogImpl.LOG.cleanLog();
4040
}
41-
runReload((EntityPlayerMP) sender, server);
41+
runReload(player, server);
4242
}
4343
}));
4444

4545
addSubcommand(new SimpleCommand("check", (server, sender, args) -> {
46-
if (sender instanceof EntityPlayerMP) {
46+
if (sender instanceof EntityPlayerMP player) {
4747
sender.sendMessage(new TextComponentString("Checking groovy syntax..."));
4848
long time = System.currentTimeMillis();
4949
GroovyScript.getSandbox().checkSyntax();
5050
time = System.currentTimeMillis() - time;
5151
sender.sendMessage(new TextComponentString("Checking syntax took " + time + "ms"));
52-
GroovyScript.postScriptRunResult((EntityPlayerMP) sender, false, false, false, time);
52+
GroovyScript.postScriptRunResult(player, false, false, false, time);
5353
}
5454
}));
5555

@@ -168,20 +168,17 @@ public static boolean hasArgument(String[] args, String arg) {
168168
}
169169

170170
@Override
171-
@NotNull
172-
public String getName() {
171+
public @NotNull String getName() {
173172
return "groovyscript";
174173
}
175174

176175
@Override
177-
@NotNull
178-
public List<String> getAliases() {
176+
public @NotNull List<String> getAliases() {
179177
return Arrays.asList("grs", "gs");
180178
}
181179

182180
@Override
183-
@NotNull
184-
public String getUsage(@NotNull ICommandSender sender) {
181+
public @NotNull String getUsage(@NotNull ICommandSender sender) {
185182
return "/grs []";
186183
}
187184
}

src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/FluidRecipe.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,12 +227,11 @@ private boolean tryRecipe(World world, BlockPos pos, List<ItemContainer> itemsIn
227227
*/
228228
public abstract void handleRecipeResult(World world, BlockPos pos);
229229

230-
@Nullable
231-
public static Fluid getFluid(IBlockState state) {
230+
public static @Nullable Fluid getFluid(IBlockState state) {
232231
Block block = state.getBlock();
233232

234-
if (block instanceof IFluidBlock) {
235-
return ((IFluidBlock) block).getFluid();
233+
if (block instanceof IFluidBlock iFluidBlock) {
234+
return iFluidBlock.getFluid();
236235
}
237236
if (block instanceof BlockLiquid) {
238237
if (state.getMaterial() == Material.WATER) {

src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/FluidToItem.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public void handleRecipeResult(World world, BlockPos pos) {
122122

123123
public static class RecipeBuilder extends FluidRecipe.RecipeBuilder<FluidToItem.Recipe> {
124124

125-
private float fluidConsumptionChance = 1f;
125+
private float fluidConsumptionChance = 1.0f;
126126

127127
public RecipeBuilder fluidInput(FluidStack fluidStack, float fluidConsumptionChance) {
128128
fluidInput(fluidStack);
@@ -144,7 +144,7 @@ public void validate(GroovyLog.Msg msg) {
144144
validateItems(msg, 1, Recipe.MAX_ITEM_INPUT, 1, 1);
145145
validateFluids(msg, 1, 1, 0, 0);
146146
validateChances(msg);
147-
this.fluidConsumptionChance = MathHelper.clamp(this.fluidConsumptionChance, 0f, 1f);
147+
this.fluidConsumptionChance = MathHelper.clamp(this.fluidConsumptionChance, 0.0f, 1.0f);
148148
}
149149

150150
@Override

0 commit comments

Comments
 (0)