Skip to content

Commit

Permalink
fix NPE on fermenter, improper energy/water consumption, and migrate …
Browse files Browse the repository at this point in the history
…to blob builds
  • Loading branch information
SchnTgaiSpock committed Jan 1, 2024
1 parent 1fda0bf commit ed8a095
Show file tree
Hide file tree
Showing 12 changed files with 167 additions and 105 deletions.
19 changes: 14 additions & 5 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
name: Java CI
# Modified from https://blob.build/docs/upload/github-action/
name: Publish build

on:
push:
tags:
- "*"
pull_request:
branches:
- master

jobs:
build:
publish:
name: Upload build
runs-on: ubuntu-latest
if: contains(github.event.head_commit.message, '[ci skip]') == false

steps:
- uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3.4.1
with:
java-version: "17"
distribution: "adopt"

- name: Build with Maven
run: mvn clean package

- name: Upload to Blob Builds
uses: WalshyDev/blob-builds/gh-action@main
with:
project: Gastronomicon
apiToken: ${{ secrets.BLOB_BUILDS_API_TOKEN }}
releaseNotes: ${{ github.event.head_commit.message }}
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.schntgaispock.gastronomicon</groupId>
<artifactId>Gastronomicon</artifactId>
<version>1.0.6</version>
<version>1.0.7</version>

<properties>
<maven.compiler.source>17</maven.compiler.source>
Expand Down Expand Up @@ -95,7 +95,7 @@
<dependency>
<groupId>com.github.Slimefun</groupId>
<artifactId>Slimefun4</artifactId>
<version>RC-35</version>
<version>RC-36</version>
<scope>provided</scope>
<exclusions>
<exclusion>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package io.github.schntgaispock.gastronomicon;

import java.util.logging.Level;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

Expand All @@ -22,6 +20,7 @@
import io.github.schntgaispock.gastronomicon.integration.DynaTechSetup;
import io.github.schntgaispock.gastronomicon.integration.SlimeHUDSetup;
import io.github.schntgaispock.gastronomicon.util.StringUtil;
import io.github.thebusybiscuit.slimefun4.libraries.dough.updater.BlobBuildUpdater;
import lombok.Getter;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.TextColor;
Expand All @@ -40,12 +39,22 @@ public Gastronomicon() {
}

@Override
@SuppressWarnings("deprecation")
public void enable() {
instance = this;

getLogger().info("#======================================#");
getLogger().info("# Gastronomicon by SchnTgaiSpock #");
getLogger().info("#======================================#");
info("#======================================#");
info("# Gastronomicon by SchnTgaiSpock #");
info("#======================================#");

if (getConfig().getBoolean("options.auto-update")) {
if (getDescription().getVersion().startsWith("Dev - ")) {
new BlobBuildUpdater(this, getFile(), "Gastronomicon", "Dev").start();
} else {
info("This is an unofficial build of Gastronomicon, so auto updates are disabled!");
info("You can download the official build here: https://blob.build/project/Gastronomicon");
}
}

final Metrics metrics = new Metrics(this, 16941);

Expand All @@ -59,31 +68,31 @@ public void enable() {

if (isPluginEnabled("SlimeHUD")) {
try {
log(Level.INFO, "SlimeHUD was found on this server!");
log(Level.INFO, "Setting up Gastronomicon for SlimeHUD...");
info("SlimeHUD was found on this server!");
info("Setting up Gastronomicon for SlimeHUD...");
SlimeHUDSetup.setup();
} catch (NoClassDefFoundError e) {
log(Level.WARNING, "This server is using an incompatitable version of SlimeHUD");
log(Level.WARNING, "Please update SlimeHUD to version 1.2.0 or higher!");
warn("This server is using an incompatitable version of SlimeHUD");
warn("Please update SlimeHUD to version 1.2.0 or higher!");
}
}

// If disable-exotic-garden-recipes is true "!" will change it to false and the rest of the code won't run.
// If disable-exotic-garden-recipes is false "!" will change it to true and the rest of the code will run checking for ExoticGarden.

if (!getConfig().getBoolean("disable-exotic-garden-recipes") && !isPluginEnabled("ExoticGarden")) {
log(Level.WARNING, "ExoticGarden was not found on this server!");
log(Level.WARNING, "Recipes that require ExoticGarden items will be hidden.");
warn("ExoticGarden was not found on this server!");
warn("Recipes that require ExoticGarden items will be hidden.");
}

if (isPluginEnabled("DynaTech") && !getConfig().getBoolean("disable-dynatech-integration")) {
try {
log(Level.INFO, "DynaTech was found on this server!");
log(Level.INFO, "Registering Gastronomicon crops with DynaTech...");
info("DynaTech was found on this server!");
info("Registering Gastronomicon crops with DynaTech...");
DynaTechSetup.setup();
} catch (NoClassDefFoundError e) {
log(Level.WARNING, "This server is using an incompatitable version of DynaTech");
log(Level.WARNING, "Please keep Gastronomicon and DynaTech up to date!");
warn("This server is using an incompatitable version of DynaTech");
warn("Please keep Gastronomicon and DynaTech up to date!");
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.schntgaispock.gastronomicon.core.listeners;

import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.SoundCategory;
Expand Down Expand Up @@ -29,6 +30,10 @@ public void onRefill(PlayerInteractEvent e) {
if (e.getAction() != Action.RIGHT_CLICK_BLOCK || !e.getPlayer().isSneaking())
return;

if (e.getItem() == null) {
return;
}

final Block b = e.getClickedBlock();
if (b == null)
return;
Expand Down Expand Up @@ -72,7 +77,10 @@ public void onRefill(PlayerInteractEvent e) {

ChunkPDC.set(b, GastroKeys.FERMENTER_WATER, Math.min(water + refill, fermenter.getCapacity()));
b.getWorld().playSound(b.getLocation(), Sound.ITEM_BUCKET_FILL, SoundCategory.PLAYERS, 1f, 1f);
e.getItem().setType(ret);

if (e.getPlayer().getGameMode() != GameMode.CREATIVE) {
e.getItem().setType(ret);
}
}

public static void setup() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1793,9 +1793,7 @@ protected boolean canCatch(Location l) {
.ingredients(BBQ_SAUCE, MUTTON)
.temperature(Temperature.HIGH)
.register(gn);
}

if (egAvailable) {
new GastroFoodBuilder()
.type(GastroRecipeType.MULTI_STOVE)
.item(GastroStacks.BUTTER_CHICKEN)
Expand Down Expand Up @@ -2234,13 +2232,14 @@ protected boolean canCatch(Location l) {
.tools(GastroStacks.BLENDER)
.register(gn);

new GastroFoodBuilder()
.type(GastroRecipeType.CULINARY_WORKBENCH)
.item(GastroStacks.STRAWBERRY_SHAVED_ICE)
.ingredients(ICE, STRAWBERRY)
.container(GastroStacks.STEEL_BOWL)
.tools(GastroStacks.BLENDER)
.register(gn);
if (egAvailable)
new GastroFoodBuilder()
.type(GastroRecipeType.CULINARY_WORKBENCH)
.item(GastroStacks.STRAWBERRY_SHAVED_ICE)
.ingredients(ICE, STRAWBERRY)
.container(GastroStacks.STEEL_BOWL)
.tools(GastroStacks.BLENDER)
.register(gn);

new GastroFoodBuilder()
.type(GastroRecipeType.CULINARY_WORKBENCH)
Expand All @@ -2250,13 +2249,14 @@ protected boolean canCatch(Location l) {
.tools(GastroStacks.BLENDER)
.register(gn);

new GastroFoodBuilder()
.type(GastroRecipeType.CULINARY_WORKBENCH)
.item(GastroStacks.LEMON_SHAVED_ICE)
.ingredients(ICE, LEMON)
.container(GastroStacks.STEEL_BOWL)
.tools(GastroStacks.BLENDER)
.register(gn);
if (egAvailable)
new GastroFoodBuilder()
.type(GastroRecipeType.CULINARY_WORKBENCH)
.item(GastroStacks.LEMON_SHAVED_ICE)
.ingredients(ICE, LEMON)
.container(GastroStacks.STEEL_BOWL)
.tools(GastroStacks.BLENDER)
.register(gn);

new GastroFoodBuilder()
.type(GastroRecipeType.CULINARY_WORKBENCH)
Expand All @@ -2268,53 +2268,56 @@ protected boolean canCatch(Location l) {
null, STICK, null)
.register(gn);

new GastroFoodBuilder()
.type(GastroRecipeType.MULTI_STOVE)
.item(GastroStacks.DONUT)
.ingredients(GastroStacks.DOUGH, YEAST, MILK_BUCKET, SlimefunItems.BUTTER, SUGAR, PINK_DYE)
.tools(GastroStacks.BAKING_TRAY)
.amount(2)
.register(gn);
if (egAvailable) {
new GastroFoodBuilder()
.type(GastroRecipeType.MULTI_STOVE)
.item(GastroStacks.DONUT)
.ingredients(GastroStacks.DOUGH, YEAST, MILK_BUCKET, SlimefunItems.BUTTER, SUGAR, PINK_DYE)
.tools(GastroStacks.BAKING_TRAY)
.amount(2)
.register(gn);

new GastroFoodBuilder()
.type(GastroRecipeType.MULTI_STOVE)
.item(GastroStacks.HONEY_DIP_DONUT)
.ingredients(GastroStacks.DOUGH, YEAST, MILK_BUCKET, SlimefunItems.BUTTER, SUGAR, HONEY_BOTTLE)
.tools(GastroStacks.BAKING_TRAY)
.amount(2)
.register(gn);
new GastroFoodBuilder()
.type(GastroRecipeType.MULTI_STOVE)
.item(GastroStacks.HONEY_DIP_DONUT)
.ingredients(GastroStacks.DOUGH, YEAST, MILK_BUCKET, SlimefunItems.BUTTER, SUGAR, HONEY_BOTTLE)
.tools(GastroStacks.BAKING_TRAY)
.amount(2)
.register(gn);

new GastroFoodBuilder()
.type(GastroRecipeType.MULTI_STOVE)
.item(GastroStacks.GOLDEN_CHOCOLATE_DONUT)
.ingredients(GastroStacks.DOUGH, YEAST, MILK_BUCKET, SlimefunItems.BUTTER, SUGAR, HONEY_BOTTLE, COCOA_BEANS)
.tools(GastroStacks.BAKING_TRAY)
.amount(2)
.register(gn);
new GastroFoodBuilder()
.type(GastroRecipeType.MULTI_STOVE)
.item(GastroStacks.GOLDEN_CHOCOLATE_DONUT)
.ingredients(GastroStacks.DOUGH, YEAST, MILK_BUCKET, SlimefunItems.BUTTER, SUGAR, HONEY_BOTTLE,
COCOA_BEANS)
.tools(GastroStacks.BAKING_TRAY)
.amount(2)
.register(gn);

new GastroFoodBuilder()
.type(GastroRecipeType.MULTI_STOVE)
.item(GastroStacks.STRAWBERRY_CHEESECAKE)
.ingredients(GastroStacks.DOUGH, YEAST, MILK_BUCKET, SlimefunItems.BUTTER, SUGAR, SlimefunItems.CHEESE,
STRAWBERRY)
.tools(GastroStacks.BAKING_TRAY)
.register(gn);
new GastroFoodBuilder()
.type(GastroRecipeType.MULTI_STOVE)
.item(GastroStacks.STRAWBERRY_CHEESECAKE)
.ingredients(GastroStacks.DOUGH, YEAST, MILK_BUCKET, SlimefunItems.BUTTER, SUGAR, SlimefunItems.CHEESE,
STRAWBERRY)
.tools(GastroStacks.BAKING_TRAY)
.register(gn);

new GastroFoodBuilder()
.type(GastroRecipeType.MULTI_STOVE)
.item(GastroStacks.STRAWBERRY_CUPCAKE)
.ingredients(GastroStacks.DOUGH, YEAST, MILK_BUCKET, SlimefunItems.BUTTER, SUGAR, STRAWBERRY)
.tools(GastroStacks.BAKING_TRAY)
.amount(2)
.register(gn);
new GastroFoodBuilder()
.type(GastroRecipeType.MULTI_STOVE)
.item(GastroStacks.STRAWBERRY_CUPCAKE)
.ingredients(GastroStacks.DOUGH, YEAST, MILK_BUCKET, SlimefunItems.BUTTER, SUGAR, STRAWBERRY)
.tools(GastroStacks.BAKING_TRAY)
.amount(2)
.register(gn);

new GastroFoodBuilder()
.type(GastroRecipeType.MULTI_STOVE)
.item(GastroStacks.LEMON_TART)
.ingredients(LEMON, SUGAR, EGG)
.tools(GastroStacks.BAKING_TRAY)
.amount(3)
.register(gn);
new GastroFoodBuilder()
.type(GastroRecipeType.MULTI_STOVE)
.item(GastroStacks.LEMON_TART)
.ingredients(LEMON, SUGAR, EGG)
.tools(GastroStacks.BAKING_TRAY)
.amount(3)
.register(gn);
}

new GastroFoodBuilder()
.type(GastroRecipeType.MULTI_STOVE)
Expand Down Expand Up @@ -2344,17 +2347,17 @@ protected boolean canCatch(Location l) {
.ingredients(RecipeUtil.cyclic(SlimefunItems.GOLD_24K_BLOCK, MELON_SLICE))
.register(gn);

new GastroFoodBuilder()
.type(GastroRecipeType.CULINARY_WORKBENCH)
.item(GastroStacks.V7)
.shape(RecipeShape.SHAPELESS)
.ingredients(TOMATO, CARROT, GastroStacks.CELERY, BEETROOT, LETTUCE, GastroStacks.PARSLEY,
GastroStacks.SPINACH)
.tools(GastroStacks.BLENDER)
.container(SlimefunItems.TIN_CAN)
.register(gn);

if (egAvailable) {
new GastroFoodBuilder()
.type(GastroRecipeType.CULINARY_WORKBENCH)
.item(GastroStacks.V7)
.shape(RecipeShape.SHAPELESS)
.ingredients(TOMATO, CARROT, GastroStacks.CELERY, BEETROOT, LETTUCE, GastroStacks.PARSLEY,
GastroStacks.SPINACH)
.tools(GastroStacks.BLENDER)
.container(SlimefunItems.TIN_CAN)
.register(gn);

new GastroFoodBuilder()
.type(GastroRecipeType.CULINARY_WORKBENCH)
.item(GastroStacks.BUBBLE_MILK_TEA)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public GastroRecipeType getGastroRecipeType() {
}

@Override
protected boolean canCraft(BlockMenu menu, Block b, Player p) {
protected boolean canCraft(BlockMenu menu, Block b, Player p, boolean sendMessage) {
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.inventory.ItemStack;

import io.github.schntgaispock.gastronomicon.Gastronomicon;
import io.github.schntgaispock.gastronomicon.core.slimefun.recipes.GastroRecipeType;
import io.github.schntgaispock.gastronomicon.util.ChunkPDC;
import io.github.schntgaispock.gastronomicon.util.item.GastroKeys;
Expand Down Expand Up @@ -51,13 +52,20 @@ public GastroRecipeType getGastroRecipeType() {
}

@Override
protected boolean canCraft(BlockMenu menu, Block b, Player p) {
protected boolean canCraft(BlockMenu menu, Block b, Player p, boolean sendMessage) {
final int water = ChunkPDC.getOrCreateDefault(b, GastroKeys.FERMENTER_WATER, 0);
if (water < getMbPerCraft())
if (water < getMbPerCraft()) {
Gastronomicon.sendMessage(p, "&eNot enough water!");
return false;
}

ChunkPDC.set(b, GastroKeys.FERMENTER_WATER, water - getMbPerCraft());
return true;
}

@Override
protected void onSuccessfulCraft(Block b) {
final int water = ChunkPDC.getOrCreateDefault(b, GastroKeys.FERMENTER_WATER, 0);
ChunkPDC.set(b, GastroKeys.FERMENTER_WATER, water - getMbPerCraft());
}

}
Loading

0 comments on commit ed8a095

Please sign in to comment.