Skip to content

Commit

Permalink
refactor: various changes (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
ybw0014 authored Aug 15, 2024
1 parent eb94291 commit 40c3b19
Show file tree
Hide file tree
Showing 50 changed files with 220 additions and 279 deletions.
2 changes: 1 addition & 1 deletion LOCALES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This addon is available in the following languages:

## SlimefunTranslation

This plugin supports [SlimefunTranslation](https://github.com/ybw0014/SlimefunTranslation).
This plugin supports [SlimefunTranslation](https://github.com/ybw0014/SlimefunTranslation) for per-player localization.

## Contribution

Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

[English](README.md) | [中文](README.zh_CN.md)

This Slimefun addon extracts the manual machines from [FinalTECH](https://github.com/ecro-fun/FinalTECH) and made some changes to put them into a separate addon.
Fast machines are Slimefun basic machines, but they cost energy to run and can craft items without recipe to be in order.
This Slimefun addon extracts the manual machines from FinalTECH and made some changes to put them into a separate addon.
Fast machines are manual crafters that cost energy to run and can craft items without recipe to be in order. Also supports bulk crafting.

Credit: Final_Root

Expand All @@ -14,6 +14,8 @@ Download from:
- [Blob builds](https://blob.build/project/FastMachines)
- [Guizhan Builds![Build Status](https://builds.guizhanss.com/ybw0014/FastMachines/master/badge.svg)](https://builds.guizhanss.com/ybw0014/FastMachines/master)

This plugin supports [SlimefunTranslation](https://github.com/ybw0014/SlimefunTranslation) for per-player localization.

## Configuration

### General Config (config.yml)
Expand All @@ -26,7 +28,7 @@ Download from:

### Item-specific config (/plugins/Slimefun/Items.yml)

The following settings are available for each individual Fast Machines:
The following settings are available for each individual Fast Machines (default settings may vary due to the original crafter's energy consumption):

- `energy-per-use`: The energy cost of each crafting operation. (default: `8`, range: `0` - `2,147,483,647` (2^31-1))
- `energy-capacity`: The energy capacity of the machine. (default: `1024`, range: `0` - `2,147,483,647` (2^31-1))
Expand Down
3 changes: 2 additions & 1 deletion README.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[English](README.md) | [中文](README.zh_CN.md)

该粘液科技附属将快速机器的玩法从[乱序技艺](https://github.com/ecro-fun/FinalTECH)中提取出来,并进行了一些改动,使其作为一个单独的附属。
快捷机器是手动的消耗电力来进行合成的机器,无需将配方按顺序摆放,支持批量合成。

鸣谢:Final_Root

Expand All @@ -22,7 +23,7 @@

### 物品特定配置(/plugins/Slimefun/Items.yml)

以下设置适用于每个独立的快速机器
以下设置适用于每个独立的快捷机器(默认值可能因原合成机器的电力消耗而改变)

- `energy-per-use`:每次制作操作的电力消耗(默认值:`8`,范围:`0` - `2,147,483,647` (2^31-1))
- `energy-capacity`:机器可存储的电力(默认值:`8`,范围:`0` - `2,147,483,647` (2^31-1))
Expand Down
7 changes: 0 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,5 @@
<version>8af2379a01</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>net.guizhanss</groupId>
<artifactId>GuizhanLibPlugin</artifactId>
<version>1.7.6</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
3 changes: 2 additions & 1 deletion src/main/java/net/guizhanss/fastmachines/core/Registry.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@

@Getter
public final class Registry {
private final List<AbstractFastMachine> allEnabledFastMachines = new ArrayList<>();

private final List<AbstractFastMachine> enabledFastMachines = new ArrayList<>();
}
18 changes: 18 additions & 0 deletions src/main/java/net/guizhanss/fastmachines/core/recipes/IRecipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* This interface represents a recipe used by a {@link AbstractFastMachine}.
*/
public interface IRecipe {

/**
* Get all the possible outputs.
*
Expand All @@ -21,11 +22,28 @@ public interface IRecipe {
@Nonnull
ItemStack[] getAllOutputs();

/**
* Get the output for the given world. Can use `isDisabledIn` check.
*
* @param world The {@link World}.
* @return The output in the given world.
*/
@Nonnull
ItemStack getOutput(@Nonnull World world);

/**
* Check if every output is disabled in the given world.
*
* @param world The {@link World}.
* @return True if every output is disabled in the given world.
*/
boolean isDisabledInWorld(@Nonnull World world);

/**
* Get the ingredients.
*
* @return A map of ingredients. The key {@link ItemStack} should always have the amount of 1, and the value {@link Integer} should be the amount of the ingredient.
*/
@Nonnull
Map<ItemStack, Integer> getInput();
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
import net.guizhanss.fastmachines.utils.RecipeUtils;

/**
* A {@link RandomRecipe} is a recipe that contains only one fixed output {@link ItemStack}.
* A {@link RandomRecipe} is a recipe that contains only one fixed input {@link ItemStack}.
*
* @author ybw0014
*/
public class RandomRecipe implements IRecipe {

private final List<ItemStack> outputs;
private final ItemStack input;

Expand Down Expand Up @@ -51,18 +52,9 @@ public int hashCode() {

@Override
public String toString() {
return "RandomRecipe{" +
"input=" + input +
", outputs=" + outputs +
'}';
return "RandomRecipe{input=" + input + ", outputs=" + outputs + '}';
}

/**
* Check whether all the output items are disabled in the given {@link World}.
*
* @param world The world to check.
* @return True if all the output items are disabled in the given {@link World}.
*/
@Override
public boolean isDisabledInWorld(@Nonnull World world) {
for (ItemStack output : outputs) {
Expand Down Expand Up @@ -90,7 +82,7 @@ public void addOutput(@Nonnull Collection<ItemStack> output) {
@Nonnull
@Override
public Map<ItemStack, Integer> getInput() {
return RecipeUtils.calculateItems(input);
return RecipeUtils.countItems(input);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ public int hashCode() {

@Override
public String toString() {
return "RawRecipe{" +
"input=" + Arrays.toString(input) +
", output=" + Arrays.toString(output) +
'}';
return "RawRecipe{input=" + Arrays.toString(input) + ", output=" + Arrays.toString(output) + '}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@
* @author ybw0014
*/
public class StandardRecipe implements IRecipe {

private final ItemStack output;
@Getter
private final Map<ItemStack, Integer> input;

public StandardRecipe(ItemStack output, ItemStack... input) {
this.output = output;
this.input = RecipeUtils.calculateItems(input);
this.input = RecipeUtils.countItems(input);
}

public StandardRecipe(ItemStack output, List<ItemStack> input) {
Expand All @@ -50,18 +51,9 @@ public int hashCode() {

@Override
public String toString() {
return "StandardRecipe{" +
"output=" + output +
", input=" + input +
'}';
return "StandardRecipe{" + "output=" + output + ", input=" + input + '}';
}

/**
* Check whether the output item is disabled in the given {@link World}.
*
* @param world The world to check.
* @return True if output item is disabled in the given {@link World}.
*/
@Override
public boolean isDisabledInWorld(@Nonnull World world) {
SlimefunItem sfItem = SlimefunItem.getByItem(output);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package net.guizhanss.fastmachines.core.services;

import lombok.Getter;
import javax.annotation.Nonnull;

import net.guizhanss.fastmachines.FastMachines;
import net.guizhanss.guizhanlib.slimefun.addon.AddonConfig;

import javax.annotation.Nonnull;
import lombok.Getter;

public final class ConfigurationService {

private final AddonConfig config;

@Getter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import lombok.Getter;

public final class IntegrationService {

private final FastMachines plugin;

@Getter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.guizhanss.fastmachines.listeners.SlimefunRegistryLoadedListener;

public final class ListenerService {

public ListenerService(@Nonnull FastMachines plugin) {
new SlimefunRegistryLoadedListener(plugin);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

@SuppressWarnings("ConstantConditions")
public final class LocalizationService extends SlimefunLocalization {

private static final String FOLDER_NAME = "lang";
private final FastMachines plugin;
private final File jarFile;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

@UtilityClass
public final class FastMachinesItems {

// <editor-fold desc="Materials">
public static final SlimefunItemStack ETERNAL_FIRE = FastMachines.getLocalization().getItem(
"ETERNAL_FIRE",
Expand Down

This file was deleted.

Loading

0 comments on commit 40c3b19

Please sign in to comment.