Skip to content

Commit

Permalink
Merge branch 'refs/heads/dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
StarWishsama committed Oct 14, 2024
2 parents 0021742 + b5c0ddf commit b974f06
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 40 deletions.
18 changes: 0 additions & 18 deletions .pre-commit-config.yaml

This file was deleted.

10 changes: 2 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -449,14 +449,8 @@

<dependency>
<groupId>net.guizhanss</groupId>
<artifactId>GuizhanLib-common</artifactId>
<version>1.6.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.guizhanss</groupId>
<artifactId>GuizhanLib-updater</artifactId>
<version>1.6.1</version>
<artifactId>guizhanlib-updater</artifactId>
<version>2.1.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ private SlimefunItems() {}
public static final SlimefunItemStack PICKAXE_OF_CONTAINMENT =
new SlimefunItemStack("PICKAXE_OF_CONTAINMENT", Material.IRON_PICKAXE, "&c刷怪笼之镐", "", "&9可以获取刷怪笼");
public static final SlimefunItemStack EXPLOSIVE_PICKAXE = new SlimefunItemStack(
"EXPLOSIVE_PICKAXE", Material.DIAMOND_PICKAXE, "&e爆炸镐", "", "&r允许你在一瞬间挖掘矿物", "", "&9在挖矿时有时运效果");
"EXPLOSIVE_PICKAXE", Material.DIAMOND_PICKAXE, "&e爆炸镐", "", "&r用爆炸快速开采矿物", "", "&9支持时运附魔");
public static final SlimefunItemStack EXPLOSIVE_SHOVEL =
new SlimefunItemStack("EXPLOSIVE_SHOVEL", Material.DIAMOND_SHOVEL, "&e爆炸铲", "", "&r让你一下子就能挖掉很多方块");
public static final SlimefunItemStack PICKAXE_OF_THE_SEEKER = new SlimefunItemStack(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines;

import city.norain.slimefun4.SlimefunExtended;
import io.github.bakedlibs.dough.inventory.InvUtils;
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
Expand All @@ -17,6 +18,7 @@
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.potion.PotionData;
import org.bukkit.potion.PotionType;

/**
Expand Down Expand Up @@ -100,6 +102,15 @@ public AutoBrewer(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipe

@ParametersAreNonnullByDefault
private @Nullable ItemStack brew(Material input, Material potionType, PotionMeta potion) {
if (SlimefunExtended.getMinecraftVersion().isAtLeast(1, 20, 2)) {
return brewPostBasePotionType(input, potionType, potion);
} else {
return brewPreBasePotionType(input, potionType, potion);
}
}

@ParametersAreNonnullByDefault
private ItemStack brewPostBasePotionType(Material input, Material potionType, PotionMeta potion) {
PotionType type = potion.getBasePotionType();
if (type == PotionType.WATER) {
if (input == Material.FERMENTED_SPIDER_EYE) {
Expand Down Expand Up @@ -140,6 +151,49 @@ public AutoBrewer(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipe
return null;
}

@ParametersAreNonnullByDefault
@SuppressWarnings("deprecration")
private ItemStack brewPreBasePotionType(Material input, Material potionType, PotionMeta potion) {
PotionData data = potion.getBasePotionData();
PotionType type = data.getType();
if (type == PotionType.WATER) {
if (input == Material.FERMENTED_SPIDER_EYE) {
potion.setBasePotionData(new PotionData(PotionType.WEAKNESS, false, false));
return new ItemStack(potionType);
} else if (input == Material.NETHER_WART) {
potion.setBasePotionData(new PotionData(PotionType.AWKWARD, false, false));
return new ItemStack(potionType);
} else if (potionType == Material.POTION && input == Material.GUNPOWDER) {
return new ItemStack(Material.SPLASH_POTION);
} else if (potionType == Material.SPLASH_POTION && input == Material.DRAGON_BREATH) {
return new ItemStack(Material.LINGERING_POTION);
}
} else if (input == Material.FERMENTED_SPIDER_EYE) {
PotionType fermented = fermentations.get(type);

if (fermented != null) {
potion.setBasePotionData(new PotionData(fermented, data.isExtended(), data.isUpgraded()));
return new ItemStack(potionType);
}
} else if (input == Material.REDSTONE && type.isExtendable() && !data.isUpgraded()) {
// Fixes #3390 - Potions can only be either extended or upgraded. Not both.
potion.setBasePotionData(new PotionData(type, true, false));
return new ItemStack(potionType);
} else if (input == Material.GLOWSTONE_DUST && type.isUpgradeable() && !data.isExtended()) {
// Fixes #3390 - Potions can only be either extended or upgraded. Not both.
potion.setBasePotionData(new PotionData(type, false, true));
return new ItemStack(potionType);
} else if (type == PotionType.AWKWARD) {
PotionType potionRecipe = potionRecipes.get(input);

if (potionRecipe != null) {
potion.setBasePotionData(new PotionData(potionRecipe, false, false));
return new ItemStack(potionType);
}
}
return null;
}

/**
* Checks whether a given {@link Material} is a valid Potion material.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package me.mrCookieSlime.CSCoreLibPlugin.general.Inventory;

import city.norain.slimefun4.holder.SlimefunInventoryHolder;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -127,17 +128,23 @@ public ChestMenu addPlayerInventoryClickHandler(MenuClickHandler handler) {
* @return The ChestMenu Instance
*/
public ChestMenu addItem(int slot, ItemStack item) {
/**
* // do shallow copy due to Paper ItemStack system change
* // See also: https://github.com/PaperMC/Paper/pull/10852
* ItemStack clone = item == null ? null : new ItemStack(item.getType(), item.getAmount());
*
* if (clone != null && item.hasItemMeta()) {
* clone.setItemMeta(item.getItemMeta());
* }*/
// do shallow copy due to Paper ItemStack system change
// See also: https://github.com/PaperMC/Paper/pull/10852
ItemStack actual = item;
if (item instanceof SlimefunItemStack) {
ItemStack clone = new ItemStack(item.getType(), item.getAmount());

if (item.hasItemMeta()) {
clone.setItemMeta(item.getItemMeta());
}

actual = clone;
}

setSize((int) (Math.max(getSize(), Math.ceil((slot + 1) / 9d) * 9)));
this.items.set(slot, item);
this.inventory.setItem(slot, item);

this.items.set(slot, actual);
this.inventory.setItem(slot, actual);
return this;
}

Expand Down
19 changes: 16 additions & 3 deletions src/main/java/net/guizhanss/slimefun4/updater/AutoUpdateTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import java.lang.reflect.Method;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import net.guizhanss.guizhanlib.updater.GuizhanBuildsCNUpdater;
import net.guizhanss.guizhanlib.updater.GuizhanBuildsUpdater;
import net.guizhanss.guizhanlib.updater.UpdaterConfig;
import org.bukkit.plugin.Plugin;

/**
Expand Down Expand Up @@ -38,13 +39,25 @@ public void run() {
}
try {
// use updater in lib plugin
Class<?> clazz = Class.forName("net.guizhanss.guizhanlibplugin.updater.GuizhanUpdater");
char[] pluginPackage = {
'n', 'e', 't', '.', 'g', 'u', 'i', 'z', 'h', 'a', 'n', 's', 's', '.', 'g', 'u', 'i', 'z', 'h', 'a', 'n',
'l', 'i', 'b', 'p', 'l', 'u', 'g', 'i', 'n'
};
Class<?> clazz = Class.forName(new String(pluginPackage) + ".updater.GuizhanUpdater");
Method updaterStart = clazz.getDeclaredMethod(
"start", Plugin.class, File.class, String.class, String.class, String.class);
updaterStart.invoke(null, plugin, file, GITHUB_USER, GITHUB_REPO, branch);
} catch (Exception ignored) {
// use updater in lib
new GuizhanBuildsCNUpdater(plugin, file, GITHUB_USER, GITHUB_REPO, branch).start();
GuizhanBuildsUpdater.start(
plugin,
file,
GITHUB_USER,
GITHUB_REPO,
branch,
UpdaterConfig.builder()
.baseUrl("https://builds.guizhanss.cn/")
.build());
}
}

Expand Down

0 comments on commit b974f06

Please sign in to comment.