Skip to content

Commit

Permalink
revert unnecessary changes
Browse files Browse the repository at this point in the history
  • Loading branch information
iTwins committed Dec 6, 2023
1 parent dc2cdad commit 530f375
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import com.google.common.base.Preconditions;

import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.block.Block;
Expand Down Expand Up @@ -47,7 +46,7 @@ public class MachineProcessor<T extends MachineOperation> {
* The owner of this {@link MachineProcessor}.
*/
public MachineProcessor(@Nonnull MachineProcessHolder<T> owner) {
Preconditions.checkArgument(owner != null, "The MachineProcessHolder cannot be null.");
Validate.notNull(owner, "The MachineProcessHolder cannot be null.");

this.owner = owner;
}
Expand Down Expand Up @@ -94,8 +93,8 @@ public void setProgressBar(@Nullable ItemStack progressBar) {
* {@link MachineOperation} has already been started at that {@link Location}.
*/
public boolean startOperation(@Nonnull Location loc, @Nonnull T operation) {
Preconditions.checkArgument(loc != null, "The location must not be null");
Preconditions.checkArgument(operation != null, "The operation cannot be null");
Validate.notNull(loc, "The location must not be null");
Validate.notNull(operation, "The operation cannot be null");

return startOperation(new BlockPosition(loc), operation);
}
Expand All @@ -112,8 +111,8 @@ public boolean startOperation(@Nonnull Location loc, @Nonnull T operation) {
* {@link MachineOperation} has already been started at that {@link Block}.
*/
public boolean startOperation(@Nonnull Block b, @Nonnull T operation) {
Preconditions.checkArgument(b != null, "The Block must not be null");
Preconditions.checkArgument(operation != null, "The machine operation cannot be null");
Validate.notNull(b, "The Block must not be null");
Validate.notNull(operation, "The machine operation cannot be null");

return startOperation(new BlockPosition(b), operation);
}
Expand All @@ -130,8 +129,8 @@ public boolean startOperation(@Nonnull Block b, @Nonnull T operation) {
* {@link MachineOperation} has already been started at that {@link BlockPosition}.
*/
public boolean startOperation(@Nonnull BlockPosition pos, @Nonnull T operation) {
Preconditions.checkArgument(pos != null, "The BlockPosition must not be null");
Preconditions.checkArgument(operation != null, "The machine operation cannot be null");
Validate.notNull(pos, "The BlockPosition must not be null");
Validate.notNull(operation, "The machine operation cannot be null");

return machines.putIfAbsent(pos, operation) == null;
}
Expand All @@ -145,7 +144,7 @@ public boolean startOperation(@Nonnull BlockPosition pos, @Nonnull T operation)
* @return The current {@link MachineOperation} or null.
*/
public @Nullable T getOperation(@Nonnull Location loc) {
Preconditions.checkArgument(loc != null, "The location cannot be null");
Validate.notNull(loc, "The location cannot be null");

return getOperation(new BlockPosition(loc));
}
Expand All @@ -159,7 +158,7 @@ public boolean startOperation(@Nonnull BlockPosition pos, @Nonnull T operation)
* @return The current {@link MachineOperation} or null.
*/
public @Nullable T getOperation(@Nonnull Block b) {
Preconditions.checkArgument(b != null, "The Block cannot be null");
Validate.notNull(b, "The Block cannot be null");

return getOperation(new BlockPosition(b));
}
Expand All @@ -173,7 +172,7 @@ public boolean startOperation(@Nonnull BlockPosition pos, @Nonnull T operation)
* @return The current {@link MachineOperation} or null.
*/
public @Nullable T getOperation(@Nonnull BlockPosition pos) {
Preconditions.checkArgument(pos != null, "The BlockPosition must not be null");
Validate.notNull(pos, "The BlockPosition must not be null");

return machines.get(pos);
}
Expand All @@ -188,7 +187,7 @@ public boolean startOperation(@Nonnull BlockPosition pos, @Nonnull T operation)
* {@link MachineOperation} to begin with.
*/
public boolean endOperation(@Nonnull Location loc) {
Preconditions.checkArgument(loc != null, "The location should not be null");
Validate.notNull(b, "The Block should not be null");

return endOperation(new BlockPosition(loc));
}
Expand All @@ -203,7 +202,7 @@ public boolean endOperation(@Nonnull Location loc) {
* {@link MachineOperation} to begin with.
*/
public boolean endOperation(@Nonnull Block b) {
Preconditions.checkArgument(b != null, "The Block should not be null");
Validate.notNull(b, "The Block should not be null");

return endOperation(new BlockPosition(b));
}
Expand All @@ -218,7 +217,7 @@ public boolean endOperation(@Nonnull Block b) {
* {@link MachineOperation} to begin with.
*/
public boolean endOperation(@Nonnull BlockPosition pos) {
Preconditions.checkArgument(pos != null, "The BlockPosition cannot be null");
Validate.notNull(pos, "The BlockPosition cannot be null");

T operation = machines.remove(pos);

Expand All @@ -241,8 +240,8 @@ public boolean endOperation(@Nonnull BlockPosition pos) {
}

public void updateProgressBar(@Nonnull BlockMenu inv, int slot, @Nonnull T operation) {
Preconditions.checkArgument(inv != null, "The inventory must not be null.");
Preconditions.checkArgument(operation != null, "The MachineOperation must not be null.");
Validate.notNull(inv, "The inventory must not be null.");
Validate.notNull(operation, "The MachineOperation must not be null.");

if (getProgressBar() == null) {
// No progress bar, no need to update anything.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;

import com.google.common.base.Preconditions;

import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
Expand Down Expand Up @@ -123,7 +122,7 @@ public int getSpeed() {
* @return This method will return the current instance of {@link GEOMiner}, so that can be chained.
*/
public final @Nonnull GEOMiner setCapacity(int capacity) {
Preconditions.checkArgument(capacity > 0, "The capacity must be greater than zero!");
Validate.isTrue(capacity > 0, "The capacity must be greater than zero!");

if (getState() == ItemState.UNREGISTERED) {
this.energyCapacity = capacity;
Expand All @@ -141,8 +140,8 @@ public int getSpeed() {
*
* @return This method will return the current instance of {@link GEOMiner}, so that can be chained.
*/
public final @Nonnull GEOMiner setProcessingSpeed(int speed) {
Preconditions.checkArgument(speed > 0, "The speed must be greater than zero!");
public final GEOMiner setProcessingSpeed(int speed) {
Validate.isTrue(speed > 0, "The speed must be greater than zero!");

this.processingSpeed = speed;
return this;
Expand All @@ -156,10 +155,10 @@ public int getSpeed() {
*
* @return This method will return the current instance of {@link GEOMiner}, so that can be chained.
*/
public final @Nonnull GEOMiner setEnergyConsumption(int energyConsumption) {
Preconditions.checkArgument(energyConsumption > 0, "The energy consumption must be greater than zero!");
Preconditions.checkArgument(energyCapacity > 0, "You must specify the capacity before you can set the consumption amount.");
Preconditions.checkArgument(energyConsumption <= energyCapacity, "The energy consumption cannot be higher than the capacity (" + energyCapacity + ')');
public final GEOMiner setEnergyConsumption(int energyConsumption) {
Validate.isTrue(energyConsumption > 0, "The energy consumption must be greater than zero!");
Validate.isTrue(energyCapacity > 0, "You must specify the capacity before you can set the consumption amount.");
Validate.isTrue(energyConsumption <= energyCapacity, "The energy consumption cannot be higher than the capacity (" + energyCapacity + ')');

this.energyConsumedPerTick = energyConsumption;
return this;
Expand Down Expand Up @@ -189,17 +188,19 @@ public void register(@Nonnull SlimefunAddon addon) {
}
}

private @Nonnull BlockPlaceHandler onBlockPlace() {
@Nonnull
private BlockPlaceHandler onBlockPlace() {
return new BlockPlaceHandler(false) {

@Override
public void onPlayerPlace(@Nonnull BlockPlaceEvent e) {
public void onPlayerPlace( BlockPlaceEvent e) {
updateHologram(e.getBlock(), "&7Idling...");
}
};
}

private @Nonnull BlockBreakHandler onBlockBreak() {
@Nonnull
private BlockBreakHandler onBlockBreak() {
return new SimpleBlockBreakHandler() {

@Override
Expand All @@ -216,18 +217,21 @@ public void onBlockBreak(@Nonnull Block b) {
};
}

@Nonnull
@Override
public @Nonnull int[] getInputSlots() {
public int[] getInputSlots() {
return new int[0];
}

@Nonnull
@Override
public @Nonnull int[] getOutputSlots() {
public int[] getOutputSlots() {
return OUTPUT_SLOTS;
}

@Nonnull
@Override
public @Nonnull List<ItemStack> getDisplayRecipes() {
public List<ItemStack> getDisplayRecipes() {
List<ItemStack> displayRecipes = new LinkedList<>();

for (GEOResource resource : Slimefun.getRegistry().getGEOResources().values()) {
Expand All @@ -245,7 +249,7 @@ public void onBlockBreak(@Nonnull Block b) {
}

@Override
public @Nonnull EnergyNetComponentType getEnergyComponentType() {
public EnergyNetComponentType getEnergyComponentType() {
return EnergyNetComponentType.CONSUMER;
}

Expand Down Expand Up @@ -324,7 +328,7 @@ private void start(@Nonnull Block b, @Nonnull BlockMenu inv) {
if (resource.isObtainableFromGEOMiner()) {
OptionalInt optional = Slimefun.getGPSNetwork().getResourceManager().getSupplies(resource, b.getWorld(), b.getX() >> 4, b.getZ() >> 4);

if (optional.isEmpty()) {
if (!optional.isPresent()) {
updateHologram(b, "&4GEO-Scan required!");
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import javax.annotation.Nonnull;

import com.google.common.base.Preconditions;

import org.apache.commons.lang.Validate;
import org.bukkit.inventory.ItemStack;

import io.github.thebusybiscuit.slimefun4.core.machines.MachineOperation;
Expand All @@ -23,16 +22,16 @@ public class MiningOperation implements MachineOperation {
private int currentTicks = 0;

public MiningOperation(@Nonnull ItemStack result, int totalTicks) {
Preconditions.checkArgument(result != null, "The result cannot be null");
Preconditions.checkArgument(totalTicks >= 0, "The amount of total ticks must be a positive integer or zero, received: " + totalTicks);
Validate.notNull(result, "The result cannot be null");
Validate.isTrue(totalTicks >= 0, "The amount of total ticks must be a positive integer or zero, received: " + totalTicks);

this.result = result;
this.totalTicks = totalTicks;
}

@Override
public void addProgress(int num) {
Preconditions.checkArgument(num > 0, "Progress must be positive.");
Validate.isTrue(num > 0, "Progress must be positive.");
currentTicks += num;
}

Expand Down

0 comments on commit 530f375

Please sign in to comment.