mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-07-30 02:55:28 +02:00
Fix sapling drops to ignore reduction and obey Knock on Wood (#5012)
* Fixed NPE when party creation doesn't use password. Solves bug reported here: https://discord.com/channels/526933440214597677/526938425161416727/1213131451235827753 Signed-off-by: Momshroom <Momshroom@gmail.com> * Actually don't reduce sapling drop if KnockOnWood unlocked. (Prior fix didn't) Signed-off-by: Momshroom <Momshroom@gmail.com> * removed unnecessary getPlayer() calls. clarified comment clarified location variable name Signed-off-by: Momshroom <Momshroom@gmail.com> * made new method more generic. Removed no longer needed dropString variable Signed-off-by: Momshroom <Momshroom@gmail.com> --------- Signed-off-by: Momshroom <Momshroom@gmail.com>
This commit is contained in:
@@ -20,6 +20,7 @@ import java.util.Collection;
|
||||
import java.util.Locale;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public final class Misc {
|
||||
private static final @NotNull Random random = new Random();
|
||||
@@ -128,6 +129,18 @@ public final class Misc {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Drops the item from the item stack only if it is a sapling (or equivalent)
|
||||
* Needed for TreeFeller
|
||||
*/
|
||||
public static void conditionallySpawn(@NotNull Predicate<String> predicate, @NotNull Player player, @NotNull Location spawnLocation, @NotNull Collection <ItemStack> drops, @NotNull ItemSpawnReason itemSpawnReason) {
|
||||
for (ItemStack drop : drops) {
|
||||
if (predicate.test(drop.getType().getKey().getKey())) {
|
||||
spawnItem(player, spawnLocation, drop, itemSpawnReason);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Drop items at a given location.
|
||||
*
|
||||
|
Reference in New Issue
Block a user