1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 03:35:51 +00:00

Apply suggestions from code review - 1

Co-authored-by: TheBusyBiscuit <TheBusyBiscuit@users.noreply.github.com>
This commit is contained in:
Sefiraat 2022-07-02 23:39:05 +01:00 committed by GitHub
parent e80f137a79
commit 58fde5cbdf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 19 additions and 20 deletions

View File

@ -124,8 +124,8 @@ public class RecipeType implements Keyed {
} else { } else {
SlimefunItem slimefunItem = SlimefunItem.getById(this.machine); SlimefunItem slimefunItem = SlimefunItem.getById(this.machine);
if (slimefunItem instanceof MultiBlockMachine multiBlockMachine) { if (slimefunItem instanceof MultiBlockMachine mbm) {
multiBlockMachine.addRecipe(recipe, result); mbm.addRecipe(recipe, result);
} }
} }
} }

View File

@ -80,8 +80,7 @@ public abstract class SubCommand {
* *
* @return A possibly localized description of this {@link SubCommand} * @return A possibly localized description of this {@link SubCommand}
*/ */
@Nonnull public @Nonnull String getDescription(@Nonnull CommandSender sender) {
public String getDescription(@Nonnull CommandSender sender) {
if (sender instanceof Player player) { if (sender instanceof Player player) {
return Slimefun.getLocalization().getMessage(player, getDescription()); return Slimefun.getLocalization().getMessage(player, getDescription());
} else { } else {

View File

@ -103,10 +103,10 @@ public class EnergyNet extends Network implements HologramOwner {
consumers.put(l, component); consumers.put(l, component);
break; break;
case GENERATOR: case GENERATOR:
if (component instanceof EnergyNetProvider energyNetProvider) { if (component instanceof EnergyNetProvider provider) {
generators.put(l, energyNetProvider); generators.put(l, provider);
} else if (component instanceof SlimefunItem slimefunItem) { } else if (component instanceof SlimefunItem item) {
slimefunItem.warn("This Item is marked as a GENERATOR but does not implement the interface EnergyNetProvider!"); item.warn("This Item is marked as a GENERATOR but does not implement the interface EnergyNetProvider!");
} }
break; break;
default: default:
@ -272,8 +272,8 @@ public class EnergyNet extends Network implements HologramOwner {
private static EnergyNetComponent getComponent(@Nonnull Location l) { private static EnergyNetComponent getComponent(@Nonnull Location l) {
SlimefunItem item = BlockStorage.check(l); SlimefunItem item = BlockStorage.check(l);
if (item instanceof EnergyNetComponent energyNetComponent) { if (item instanceof EnergyNetComponent component) {
return energyNetComponent; return component;
} }
return null; return null;

View File

@ -86,8 +86,8 @@ public abstract class AbstractMonsterSpawner extends SlimefunItem {
if (meta instanceof BlockStateMeta stateMeta) { if (meta instanceof BlockStateMeta stateMeta) {
BlockState state = stateMeta.getBlockState(); BlockState state = stateMeta.getBlockState();
if (state instanceof CreatureSpawner creatureSpawner) { if (state instanceof CreatureSpawner spawner) {
creatureSpawner.setSpawnedType(type); spawner.setSpawnedType(type);
} }
stateMeta.setBlockState(state); stateMeta.setBlockState(state);

View File

@ -67,8 +67,8 @@ public class EnhancedCraftingTable extends AbstractCraftingTable {
if (outputInv != null) { if (outputInv != null) {
SlimefunItem sfItem = SlimefunItem.getByItem(output); SlimefunItem sfItem = SlimefunItem.getByItem(output);
if (sfItem instanceof SlimefunBackpack slimefunBackpack) { if (sfItem instanceof SlimefunBackpack backpack) {
upgradeBackpack(p, inv, slimefunBackpack, output); upgradeBackpack(p, inv, backpack, output);
} }
for (int j = 0; j < 9; j++) { for (int j = 0; j < 9; j++) {

View File

@ -75,8 +75,8 @@ public class MagicWorkbench extends AbstractCraftingTable {
if (outputInv != null) { if (outputInv != null) {
SlimefunItem sfItem = SlimefunItem.getByItem(output); SlimefunItem sfItem = SlimefunItem.getByItem(output);
if (sfItem instanceof SlimefunBackpack slimefunBackpack) { if (sfItem instanceof SlimefunBackpack backpack) {
upgradeBackpack(p, inv, slimefunBackpack, output); upgradeBackpack(p, inv, backpack, output);
} }
for (int j = 0; j < 9; j++) { for (int j = 0; j < 9; j++) {

View File

@ -64,7 +64,7 @@ public class TeleporterListener implements Listener {
// Pressure plate was an elevator // Pressure plate was an elevator
ElevatorPlate elevator = SlimefunItems.ELEVATOR_PLATE.getItem(ElevatorPlate.class); ElevatorPlate elevator = SlimefunItems.ELEVATOR_PLATE.getItem(ElevatorPlate.class);
elevator.openInterface(p, b); elevator.openInterface(p, b);
} else if (item instanceof AbstractTeleporterPlate abstractTeleporterPlate && abstractTeleporterPlate.hasAccess(p, b)) { } else if (item instanceof AbstractTeleporterPlate teleporterPlate && teleporterPlate.hasAccess(p, b)) {
// Pressure plate was a teleporter // Pressure plate was a teleporter
SlimefunItem teleporter = BlockStorage.check(b.getRelative(BlockFace.DOWN)); SlimefunItem teleporter = BlockStorage.check(b.getRelative(BlockFace.DOWN));

View File

@ -132,8 +132,8 @@ public final class ItemStackWrapper extends ItemStack {
public static @Nonnull ItemStackWrapper wrap(@Nonnull ItemStack itemStack) { public static @Nonnull ItemStackWrapper wrap(@Nonnull ItemStack itemStack) {
Validate.notNull(itemStack, "The ItemStack cannot be null!"); Validate.notNull(itemStack, "The ItemStack cannot be null!");
if (itemStack instanceof ItemStackWrapper itemStackWrapper) { if (itemStack instanceof ItemStackWrapper wrapper) {
return itemStackWrapper; return wrapper;
} }
return new ItemStackWrapper(itemStack); return new ItemStackWrapper(itemStack);

View File

@ -106,7 +106,7 @@ public class TagParser implements Keyed {
JsonArray values = child.getAsJsonArray(); JsonArray values = child.getAsJsonArray();
for (JsonElement element : values) { for (JsonElement element : values) {
if (element instanceof JsonPrimitive jsonPrimitive && jsonPrimitive.isString()) { if (element instanceof JsonPrimitive primitive && primitive.isString()) {
// Strings will be parsed directly // Strings will be parsed directly
parsePrimitiveValue(element.getAsString(), materials, tags, true); parsePrimitiveValue(element.getAsString(), materials, tags, true);
} else if (element instanceof JsonObject) { } else if (element instanceof JsonObject) {