Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	.github/workflows/auto-squash.yml
#	src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java
  • Loading branch information
StarWishsama committed Mar 11, 2022
2 parents 6d1a500 + cea7204 commit c21c0bd
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 16 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@
* Fixed "Lands" integration
* Fixed #3133
* Fixed #3483
* Fixed #3469
* Fixed #3476
* Fixed #3487

## Release Candidate 30 (31 Dec 2021)
https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#30
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@
<dependency>
<groupId>net.imprex</groupId>
<artifactId>orebfuscator-api</artifactId>
<version>5.2.4</version>
<version>5.2.6</version>
<scope>provided</scope>
<exclusions>
<exclusion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,8 @@ public void setResearch(@Nullable Research research) {
/**
* Sets the recipe for this {@link SlimefunItem}.
*
* @param recipe The recipe for this {@link ItemStack}
* @param recipe
* The recipe for this {@link ItemStack}
*/
public void setRecipe(@Nonnull ItemStack[] recipe) {
if (recipe == null || recipe.length != 9) {
Expand All @@ -676,7 +677,8 @@ public void setRecipe(@Nonnull ItemStack[] recipe) {
/**
* Sets the {@link RecipeType} for this {@link SlimefunItem}.
*
* @param type The {@link RecipeType} for this {@link SlimefunItem}
* @param type
* The {@link RecipeType} for this {@link SlimefunItem}
*/
public void setRecipeType(@Nonnull RecipeType type) {
Validate.notNull(type, "The RecipeType is not allowed to be null!");
Expand Down Expand Up @@ -1137,7 +1139,8 @@ public final int hashCode() {
/**
* Retrieve a {@link SlimefunItem} by its id.
*
* @param id The id of the {@link SlimefunItem}
* @param id
* The id of the {@link SlimefunItem}
* @return The {@link SlimefunItem} associated with that id. Null if non-existent
*/
public static @Nullable SlimefunItem getById(@Nonnull String id) {
Expand All @@ -1147,7 +1150,8 @@ public final int hashCode() {
/**
* Retrieve a {@link SlimefunItem} from an {@link ItemStack}.
*
* @param item The {@link ItemStack} to check
* @param item
* The {@link ItemStack} to check
* @return The {@link SlimefunItem} associated with this {@link ItemStack} if present, otherwise null
*/
public static @Nullable SlimefunItem getByItem(@Nullable ItemStack item) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.api.items.groups.FlexItemGroup;
import io.github.thebusybiscuit.slimefun4.api.items.groups.LockedItemGroup;
import io.github.thebusybiscuit.slimefun4.api.items.groups.SubItemGroup;
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import io.github.thebusybiscuit.slimefun4.api.researches.Research;
Expand Down Expand Up @@ -366,9 +367,7 @@ public void openSearch(PlayerProfile profile, String input, boolean addToHistory
break;
}

boolean isItemGroupHidden = showHiddenItemGroupsInSearch || !slimefunItem.getItemGroup().isHidden(p);

if (!slimefunItem.isHidden() && isItemGroupHidden && isSearchFilterApplicable(slimefunItem, searchTerm)) {
if (!slimefunItem.isHidden() && !isItemGroupHidden(p, slimefunItem) && isSearchFilterApplicable(slimefunItem, searchTerm)) {
ItemStack itemstack = new CustomItemStack(slimefunItem.getItem(), meta -> {
ItemGroup itemGroup = slimefunItem.getItemGroup();
meta.setLore(Arrays.asList("", ChatColor.DARK_GRAY + "\u21E8 " + ChatColor.WHITE + itemGroup.getDisplayName(p)));
Expand Down Expand Up @@ -397,6 +396,22 @@ public void openSearch(PlayerProfile profile, String input, boolean addToHistory
menu.open(p);
}

@ParametersAreNonnullByDefault
private boolean isItemGroupHidden(Player p, SlimefunItem slimefunItem) {
if (showHiddenItemGroupsInSearch) {
return false;
}

ItemGroup itemGroup = slimefunItem.getItemGroup();

// Fixes #3487 - SubItemGroups are "pseudo-hidden"
if (itemGroup instanceof SubItemGroup) {
return false;
} else {
return itemGroup.isHidden(p);
}
}

@ParametersAreNonnullByDefault
private boolean isSearchFilterApplicable(SlimefunItem slimefunItem, String searchTerm) {
String itemName = ChatColor.stripColor(slimefunItem.getItemName()).toLowerCase(Locale.ROOT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.Map;

import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
Expand Down Expand Up @@ -115,7 +116,7 @@ public void onInteract(PlayerRightClickEvent e) {
return;
}

// Make altarinuse simply because that was the last block clicked.
// Make altar in use simply because that was the last block clicked.
altarsInUse.add(b.getLocation());
e.cancel();

Expand Down Expand Up @@ -159,6 +160,17 @@ private void usePedestal(@Nonnull Block pedestal, @Nonnull Player p) {

p.getInventory().addItem(pedestalItem.getOriginalItemStack(entity));
p.playSound(pedestal.getLocation(), Sound.ENTITY_ITEM_PICKUP, 1F, 1F);

/*
* Fixes #3476
* Drop the item instead if the player's inventory is full and
* no stack space left else add remaining items from the returned map value
*/
Map<Integer, ItemStack> remainingItemMap = p.getInventory().addItem(pedestalItem.getOriginalItemStack(entity));

for (ItemStack item : remainingItemMap.values()) {
p.getWorld().dropItem(pedestal.getLocation().add(0, 1, 0), item.clone());
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package io.github.thebusybiscuit.slimefun4.implementation.listeners;

import java.util.Optional;

import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;

Expand All @@ -16,10 +14,12 @@

import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;

import me.mrCookieSlime.Slimefun.api.BlockStorage;

/**
* The {@link MiddleClickListener} is responsible for listening to the {@link InventoryCreativeEvent}.
* The {@link MiddleClickListener} is responsible for listening to
* the {@link InventoryCreativeEvent}.
*
* @author svr333
*
Expand All @@ -30,7 +30,7 @@ public MiddleClickListener(@Nonnull Slimefun plugin) {
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}

/*
/*
* General Discloser: this event has really really really weird behavior on middle click.
* Has been tested thoroughly to make sure it doesnt break anything else.
*/
Expand Down Expand Up @@ -58,8 +58,8 @@ public void onInventoryCreativeEvent(InventoryCreativeEvent e) {
if (sfItem == null) {
return;
}
/*

/*
* Before giving the item to the user, check if you can swap
* to the item instead (user already has item in hotbar).
* This is sometimes bypassed by the client itself (not fixable though).
Expand All @@ -85,7 +85,7 @@ private boolean isActualMiddleClick(InventoryCreativeEvent e, Block b) {
* to the actual block that is middle clicked, while currentItem will be AIR.
*
* This check is really weird due to the weird nature of this event's behaviour.
* It checks if the block the player is looking at is of the same type as the cursor;
* It checks if the block the player is looking at is of the same type as the cursor,
* after this we can make sure that it is a middle click outside of the inventory
* currentItem should also be air, otherwise it is not outside of the inventory
*/
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/tags/dirt_variants.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
"id": "minecraft:dirt_path",
"required": false
},
{
"id": "minecraft:rooted_dirt",
"required": false
},
"minecraft:farmland",
"minecraft:podzol",
"minecraft:mycelium"
Expand Down

0 comments on commit c21c0bd

Please sign in to comment.