mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
revert unnecessary changes
This commit is contained in:
parent
dc2cdadc3c
commit
530f375a1f
@ -6,8 +6,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import org.apache.commons.lang.Validate;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -47,7 +46,7 @@ public class MachineProcessor<T extends MachineOperation> {
|
|||||||
* The owner of this {@link MachineProcessor}.
|
* The owner of this {@link MachineProcessor}.
|
||||||
*/
|
*/
|
||||||
public MachineProcessor(@Nonnull MachineProcessHolder<T> owner) {
|
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;
|
this.owner = owner;
|
||||||
}
|
}
|
||||||
@ -94,8 +93,8 @@ public class MachineProcessor<T extends MachineOperation> {
|
|||||||
* {@link MachineOperation} has already been started at that {@link Location}.
|
* {@link MachineOperation} has already been started at that {@link Location}.
|
||||||
*/
|
*/
|
||||||
public boolean startOperation(@Nonnull Location loc, @Nonnull T operation) {
|
public boolean startOperation(@Nonnull Location loc, @Nonnull T operation) {
|
||||||
Preconditions.checkArgument(loc != null, "The location must not be null");
|
Validate.notNull(loc, "The location must not be null");
|
||||||
Preconditions.checkArgument(operation != null, "The operation cannot be null");
|
Validate.notNull(operation, "The operation cannot be null");
|
||||||
|
|
||||||
return startOperation(new BlockPosition(loc), operation);
|
return startOperation(new BlockPosition(loc), operation);
|
||||||
}
|
}
|
||||||
@ -112,8 +111,8 @@ public class MachineProcessor<T extends MachineOperation> {
|
|||||||
* {@link MachineOperation} has already been started at that {@link Block}.
|
* {@link MachineOperation} has already been started at that {@link Block}.
|
||||||
*/
|
*/
|
||||||
public boolean startOperation(@Nonnull Block b, @Nonnull T operation) {
|
public boolean startOperation(@Nonnull Block b, @Nonnull T operation) {
|
||||||
Preconditions.checkArgument(b != null, "The Block must not be null");
|
Validate.notNull(b, "The Block must not be null");
|
||||||
Preconditions.checkArgument(operation != null, "The machine operation cannot be null");
|
Validate.notNull(operation, "The machine operation cannot be null");
|
||||||
|
|
||||||
return startOperation(new BlockPosition(b), operation);
|
return startOperation(new BlockPosition(b), operation);
|
||||||
}
|
}
|
||||||
@ -130,8 +129,8 @@ public class MachineProcessor<T extends MachineOperation> {
|
|||||||
* {@link MachineOperation} has already been started at that {@link BlockPosition}.
|
* {@link MachineOperation} has already been started at that {@link BlockPosition}.
|
||||||
*/
|
*/
|
||||||
public boolean startOperation(@Nonnull BlockPosition pos, @Nonnull T operation) {
|
public boolean startOperation(@Nonnull BlockPosition pos, @Nonnull T operation) {
|
||||||
Preconditions.checkArgument(pos != null, "The BlockPosition must not be null");
|
Validate.notNull(pos, "The BlockPosition must not be null");
|
||||||
Preconditions.checkArgument(operation != null, "The machine operation cannot be null");
|
Validate.notNull(operation, "The machine operation cannot be null");
|
||||||
|
|
||||||
return machines.putIfAbsent(pos, operation) == null;
|
return machines.putIfAbsent(pos, operation) == null;
|
||||||
}
|
}
|
||||||
@ -145,7 +144,7 @@ public class MachineProcessor<T extends MachineOperation> {
|
|||||||
* @return The current {@link MachineOperation} or null.
|
* @return The current {@link MachineOperation} or null.
|
||||||
*/
|
*/
|
||||||
public @Nullable T getOperation(@Nonnull Location loc) {
|
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));
|
return getOperation(new BlockPosition(loc));
|
||||||
}
|
}
|
||||||
@ -159,7 +158,7 @@ public class MachineProcessor<T extends MachineOperation> {
|
|||||||
* @return The current {@link MachineOperation} or null.
|
* @return The current {@link MachineOperation} or null.
|
||||||
*/
|
*/
|
||||||
public @Nullable T getOperation(@Nonnull Block b) {
|
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));
|
return getOperation(new BlockPosition(b));
|
||||||
}
|
}
|
||||||
@ -173,7 +172,7 @@ public class MachineProcessor<T extends MachineOperation> {
|
|||||||
* @return The current {@link MachineOperation} or null.
|
* @return The current {@link MachineOperation} or null.
|
||||||
*/
|
*/
|
||||||
public @Nullable T getOperation(@Nonnull BlockPosition pos) {
|
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);
|
return machines.get(pos);
|
||||||
}
|
}
|
||||||
@ -188,7 +187,7 @@ public class MachineProcessor<T extends MachineOperation> {
|
|||||||
* {@link MachineOperation} to begin with.
|
* {@link MachineOperation} to begin with.
|
||||||
*/
|
*/
|
||||||
public boolean endOperation(@Nonnull Location loc) {
|
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));
|
return endOperation(new BlockPosition(loc));
|
||||||
}
|
}
|
||||||
@ -203,7 +202,7 @@ public class MachineProcessor<T extends MachineOperation> {
|
|||||||
* {@link MachineOperation} to begin with.
|
* {@link MachineOperation} to begin with.
|
||||||
*/
|
*/
|
||||||
public boolean endOperation(@Nonnull Block b) {
|
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));
|
return endOperation(new BlockPosition(b));
|
||||||
}
|
}
|
||||||
@ -218,7 +217,7 @@ public class MachineProcessor<T extends MachineOperation> {
|
|||||||
* {@link MachineOperation} to begin with.
|
* {@link MachineOperation} to begin with.
|
||||||
*/
|
*/
|
||||||
public boolean endOperation(@Nonnull BlockPosition pos) {
|
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);
|
T operation = machines.remove(pos);
|
||||||
|
|
||||||
@ -241,8 +240,8 @@ public class MachineProcessor<T extends MachineOperation> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateProgressBar(@Nonnull BlockMenu inv, int slot, @Nonnull T operation) {
|
public void updateProgressBar(@Nonnull BlockMenu inv, int slot, @Nonnull T operation) {
|
||||||
Preconditions.checkArgument(inv != null, "The inventory must not be null.");
|
Validate.notNull(inv, "The inventory must not be null.");
|
||||||
Preconditions.checkArgument(operation != null, "The MachineOperation must not be null.");
|
Validate.notNull(operation, "The MachineOperation must not be null.");
|
||||||
|
|
||||||
if (getProgressBar() == null) {
|
if (getProgressBar() == null) {
|
||||||
// No progress bar, no need to update anything.
|
// No progress bar, no need to update anything.
|
||||||
|
@ -7,8 +7,7 @@ import java.util.OptionalInt;
|
|||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import org.apache.commons.lang.Validate;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -123,7 +122,7 @@ public class GEOMiner extends SlimefunItem implements RecipeDisplayItem, EnergyN
|
|||||||
* @return This method will return the current instance of {@link GEOMiner}, so that can be chained.
|
* @return This method will return the current instance of {@link GEOMiner}, so that can be chained.
|
||||||
*/
|
*/
|
||||||
public final @Nonnull GEOMiner setCapacity(int capacity) {
|
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) {
|
if (getState() == ItemState.UNREGISTERED) {
|
||||||
this.energyCapacity = capacity;
|
this.energyCapacity = capacity;
|
||||||
@ -141,8 +140,8 @@ public class GEOMiner extends SlimefunItem implements RecipeDisplayItem, EnergyN
|
|||||||
*
|
*
|
||||||
* @return This method will return the current instance of {@link GEOMiner}, so that can be chained.
|
* @return This method will return the current instance of {@link GEOMiner}, so that can be chained.
|
||||||
*/
|
*/
|
||||||
public final @Nonnull GEOMiner setProcessingSpeed(int speed) {
|
public final GEOMiner setProcessingSpeed(int speed) {
|
||||||
Preconditions.checkArgument(speed > 0, "The speed must be greater than zero!");
|
Validate.isTrue(speed > 0, "The speed must be greater than zero!");
|
||||||
|
|
||||||
this.processingSpeed = speed;
|
this.processingSpeed = speed;
|
||||||
return this;
|
return this;
|
||||||
@ -156,10 +155,10 @@ public class GEOMiner extends SlimefunItem implements RecipeDisplayItem, EnergyN
|
|||||||
*
|
*
|
||||||
* @return This method will return the current instance of {@link GEOMiner}, so that can be chained.
|
* @return This method will return the current instance of {@link GEOMiner}, so that can be chained.
|
||||||
*/
|
*/
|
||||||
public final @Nonnull GEOMiner setEnergyConsumption(int energyConsumption) {
|
public final GEOMiner setEnergyConsumption(int energyConsumption) {
|
||||||
Preconditions.checkArgument(energyConsumption > 0, "The energy consumption must be greater than zero!");
|
Validate.isTrue(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.");
|
Validate.isTrue(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 + ')');
|
Validate.isTrue(energyConsumption <= energyCapacity, "The energy consumption cannot be higher than the capacity (" + energyCapacity + ')');
|
||||||
|
|
||||||
this.energyConsumedPerTick = energyConsumption;
|
this.energyConsumedPerTick = energyConsumption;
|
||||||
return this;
|
return this;
|
||||||
@ -189,17 +188,19 @@ public class GEOMiner extends SlimefunItem implements RecipeDisplayItem, EnergyN
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private @Nonnull BlockPlaceHandler onBlockPlace() {
|
@Nonnull
|
||||||
|
private BlockPlaceHandler onBlockPlace() {
|
||||||
return new BlockPlaceHandler(false) {
|
return new BlockPlaceHandler(false) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerPlace(@Nonnull BlockPlaceEvent e) {
|
public void onPlayerPlace( BlockPlaceEvent e) {
|
||||||
updateHologram(e.getBlock(), "&7Idling...");
|
updateHologram(e.getBlock(), "&7Idling...");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private @Nonnull BlockBreakHandler onBlockBreak() {
|
@Nonnull
|
||||||
|
private BlockBreakHandler onBlockBreak() {
|
||||||
return new SimpleBlockBreakHandler() {
|
return new SimpleBlockBreakHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -216,18 +217,21 @@ public class GEOMiner extends SlimefunItem implements RecipeDisplayItem, EnergyN
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public @Nonnull int[] getInputSlots() {
|
public int[] getInputSlots() {
|
||||||
return new int[0];
|
return new int[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public @Nonnull int[] getOutputSlots() {
|
public int[] getOutputSlots() {
|
||||||
return OUTPUT_SLOTS;
|
return OUTPUT_SLOTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public @Nonnull List<ItemStack> getDisplayRecipes() {
|
public List<ItemStack> getDisplayRecipes() {
|
||||||
List<ItemStack> displayRecipes = new LinkedList<>();
|
List<ItemStack> displayRecipes = new LinkedList<>();
|
||||||
|
|
||||||
for (GEOResource resource : Slimefun.getRegistry().getGEOResources().values()) {
|
for (GEOResource resource : Slimefun.getRegistry().getGEOResources().values()) {
|
||||||
@ -245,7 +249,7 @@ public class GEOMiner extends SlimefunItem implements RecipeDisplayItem, EnergyN
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @Nonnull EnergyNetComponentType getEnergyComponentType() {
|
public EnergyNetComponentType getEnergyComponentType() {
|
||||||
return EnergyNetComponentType.CONSUMER;
|
return EnergyNetComponentType.CONSUMER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -324,7 +328,7 @@ public class GEOMiner extends SlimefunItem implements RecipeDisplayItem, EnergyN
|
|||||||
if (resource.isObtainableFromGEOMiner()) {
|
if (resource.isObtainableFromGEOMiner()) {
|
||||||
OptionalInt optional = Slimefun.getGPSNetwork().getResourceManager().getSupplies(resource, b.getWorld(), b.getX() >> 4, b.getZ() >> 4);
|
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!");
|
updateHologram(b, "&4GEO-Scan required!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.operations;
|
|||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import org.apache.commons.lang.Validate;
|
||||||
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import io.github.thebusybiscuit.slimefun4.core.machines.MachineOperation;
|
import io.github.thebusybiscuit.slimefun4.core.machines.MachineOperation;
|
||||||
@ -23,8 +22,8 @@ public class MiningOperation implements MachineOperation {
|
|||||||
private int currentTicks = 0;
|
private int currentTicks = 0;
|
||||||
|
|
||||||
public MiningOperation(@Nonnull ItemStack result, int totalTicks) {
|
public MiningOperation(@Nonnull ItemStack result, int totalTicks) {
|
||||||
Preconditions.checkArgument(result != null, "The result cannot be null");
|
Validate.notNull(result, "The result cannot be null");
|
||||||
Preconditions.checkArgument(totalTicks >= 0, "The amount of total ticks must be a positive integer or zero, received: " + totalTicks);
|
Validate.isTrue(totalTicks >= 0, "The amount of total ticks must be a positive integer or zero, received: " + totalTicks);
|
||||||
|
|
||||||
this.result = result;
|
this.result = result;
|
||||||
this.totalTicks = totalTicks;
|
this.totalTicks = totalTicks;
|
||||||
@ -32,7 +31,7 @@ public class MiningOperation implements MachineOperation {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addProgress(int num) {
|
public void addProgress(int num) {
|
||||||
Preconditions.checkArgument(num > 0, "Progress must be positive.");
|
Validate.isTrue(num > 0, "Progress must be positive.");
|
||||||
currentTicks += num;
|
currentTicks += num;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user