mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
parent
b9f64bdebc
commit
25dea3daf6
@ -35,6 +35,7 @@
|
|||||||
#### Changes
|
#### Changes
|
||||||
|
|
||||||
#### Fixes
|
#### Fixes
|
||||||
|
* Fixed #2966
|
||||||
|
|
||||||
## Release Candidate 25 (20 Jun 2021)
|
## Release Candidate 25 (20 Jun 2021)
|
||||||
https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#25
|
https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#25
|
||||||
|
@ -7,6 +7,7 @@ import javax.annotation.ParametersAreNonnullByDefault;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;
|
import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;
|
||||||
|
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
@ -51,7 +52,6 @@ public abstract class SimpleSlimefunItem<T extends ItemHandler> extends Slimefun
|
|||||||
*
|
*
|
||||||
* @return The {@link ItemHandler} that should be added to this {@link SlimefunItem}
|
* @return The {@link ItemHandler} that should be added to this {@link SlimefunItem}
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
public abstract @Nonnull T getItemHandler();
|
||||||
public abstract T getItemHandler();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import java.util.Map;
|
|||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
@ -27,6 +28,7 @@ import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
|
|||||||
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine;
|
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag;
|
import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag;
|
||||||
|
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel;
|
||||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||||
@ -49,9 +51,9 @@ public class IndustrialMiner extends MultiBlockMachine {
|
|||||||
protected final Map<Location, MiningTask> activeMiners = new HashMap<>();
|
protected final Map<Location, MiningTask> activeMiners = new HashMap<>();
|
||||||
protected final List<MachineFuel> fuelTypes = new ArrayList<>();
|
protected final List<MachineFuel> fuelTypes = new ArrayList<>();
|
||||||
|
|
||||||
private final int range;
|
|
||||||
private final boolean silkTouch;
|
|
||||||
private final ItemSetting<Boolean> canMineAncientDebris = new ItemSetting<>(this, "can-mine-ancient-debris", false);
|
private final ItemSetting<Boolean> canMineAncientDebris = new ItemSetting<>(this, "can-mine-ancient-debris", false);
|
||||||
|
private final boolean silkTouch;
|
||||||
|
private final int range;
|
||||||
|
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
public IndustrialMiner(Category category, SlimefunItemStack item, Material baseMaterial, boolean silkTouch, int range) {
|
public IndustrialMiner(Category category, SlimefunItemStack item, Material baseMaterial, boolean silkTouch, int range) {
|
||||||
@ -115,7 +117,7 @@ public class IndustrialMiner extends MultiBlockMachine {
|
|||||||
*
|
*
|
||||||
* @return The outcome when mining this ore
|
* @return The outcome when mining this ore
|
||||||
*/
|
*/
|
||||||
public ItemStack getOutcome(Material ore) {
|
public @Nonnull ItemStack getOutcome(@Nonnull Material ore) {
|
||||||
if (hasSilkTouch()) {
|
if (hasSilkTouch()) {
|
||||||
return new ItemStack(ore);
|
return new ItemStack(ore);
|
||||||
}
|
}
|
||||||
@ -149,8 +151,10 @@ public class IndustrialMiner extends MultiBlockMachine {
|
|||||||
* @param item
|
* @param item
|
||||||
* The item that shall be consumed
|
* The item that shall be consumed
|
||||||
*/
|
*/
|
||||||
public void addFuelType(int ores, ItemStack item) {
|
public void addFuelType(int ores, @Nonnull ItemStack item) {
|
||||||
Validate.isTrue(ores > 1 && ores % 2 == 0, "The amount of ores must be at least 2 and a multiple of 2.");
|
Validate.isTrue(ores > 1 && ores % 2 == 0, "The amount of ores must be at least 2 and a multiple of 2.");
|
||||||
|
Validate.notNull(item, "The fuel item cannot be null");
|
||||||
|
|
||||||
fuelTypes.add(new MachineFuel(ores / 2, item));
|
fuelTypes.add(new MachineFuel(ores / 2, item));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,11 +194,11 @@ public class IndustrialMiner extends MultiBlockMachine {
|
|||||||
Block start = b.getRelative(-mod, -1, -mod);
|
Block start = b.getRelative(-mod, -1, -mod);
|
||||||
Block end = b.getRelative(mod, -1, mod);
|
Block end = b.getRelative(mod, -1, mod);
|
||||||
|
|
||||||
MiningTask instance = new MiningTask(this, p.getUniqueId(), chest, pistons, start, end);
|
MiningTask task = new MiningTask(this, p.getUniqueId(), chest, pistons, start, end);
|
||||||
instance.start(b);
|
task.start(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Block[] findPistons(Block chest) {
|
private @Nonnull Block[] findPistons(@Nonnull Block chest) {
|
||||||
Block northern = chest.getRelative(BlockFace.NORTH);
|
Block northern = chest.getRelative(BlockFace.NORTH);
|
||||||
|
|
||||||
if (northern.getType() == Material.PISTON) {
|
if (northern.getType() == Material.PISTON) {
|
||||||
@ -212,7 +216,7 @@ public class IndustrialMiner extends MultiBlockMachine {
|
|||||||
*
|
*
|
||||||
* @return Whether this {@link IndustrialMiner} is capable of mining this {@link Material}
|
* @return Whether this {@link IndustrialMiner} is capable of mining this {@link Material}
|
||||||
*/
|
*/
|
||||||
public boolean canMine(Material type) {
|
public boolean canMine(@Nonnull Material type) {
|
||||||
if (SlimefunTag.INDUSTRIAL_MINER_ORES.isTagged(type)) {
|
if (SlimefunTag.INDUSTRIAL_MINER_ORES.isTagged(type)) {
|
||||||
return true;
|
return true;
|
||||||
} else if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_16)) {
|
} else if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_16)) {
|
||||||
|
@ -46,10 +46,6 @@ class MiningTask implements Runnable {
|
|||||||
private final IndustrialMiner miner;
|
private final IndustrialMiner miner;
|
||||||
private final UUID owner;
|
private final UUID owner;
|
||||||
|
|
||||||
private int fuel = 0;
|
|
||||||
private int ores = 0;
|
|
||||||
private boolean running = false;
|
|
||||||
|
|
||||||
private final Block chest;
|
private final Block chest;
|
||||||
private final Block[] pistons;
|
private final Block[] pistons;
|
||||||
|
|
||||||
@ -57,6 +53,10 @@ class MiningTask implements Runnable {
|
|||||||
private final BlockPosition end;
|
private final BlockPosition end;
|
||||||
private final int height;
|
private final int height;
|
||||||
|
|
||||||
|
private boolean running = false;
|
||||||
|
private int fuel = 0;
|
||||||
|
private int ores = 0;
|
||||||
|
|
||||||
private int x;
|
private int x;
|
||||||
private int z;
|
private int z;
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.seasonal;
|
|||||||
|
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
@ -13,6 +14,7 @@ import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable;
|
|||||||
import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;
|
import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.FireworkUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.FireworkUtils;
|
||||||
|
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
@ -39,7 +41,7 @@ public class ChristmasPresent extends SimpleSlimefunItem<ItemUseHandler> impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemUseHandler getItemHandler() {
|
public @Nonnull ItemUseHandler getItemHandler() {
|
||||||
return e -> {
|
return e -> {
|
||||||
e.cancel();
|
e.cancel();
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.seasonal;
|
|||||||
|
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
@ -39,7 +40,7 @@ public class EasterEgg extends SimpleSlimefunItem<ItemUseHandler> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemUseHandler getItemHandler() {
|
public @Nonnull ItemUseHandler getItemHandler() {
|
||||||
return e -> {
|
return e -> {
|
||||||
e.cancel();
|
e.cancel();
|
||||||
|
|
||||||
|
@ -104,23 +104,20 @@ public class GoldPan extends SimpleSlimefunItem<ItemUseHandler> implements Recip
|
|||||||
*
|
*
|
||||||
* @return a random {@link ItemStack} obtained by this {@link GoldPan}
|
* @return a random {@link ItemStack} obtained by this {@link GoldPan}
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
public @Nonnull ItemStack getRandomOutput() {
|
||||||
public ItemStack getRandomOutput() {
|
|
||||||
ItemStack item = randomizer.getRandom();
|
ItemStack item = randomizer.getRandom();
|
||||||
|
|
||||||
// Fixes #2804
|
// Fixes #2804
|
||||||
return item != null ? item : new ItemStack(Material.AIR);
|
return item != null ? item : new ItemStack(Material.AIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public String getLabelLocalPath() {
|
public @Nonnull String getLabelLocalPath() {
|
||||||
return "guide.tooltips.recipes.gold-pan";
|
return "guide.tooltips.recipes.gold-pan";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public ItemUseHandler getItemHandler() {
|
public @Nonnull ItemUseHandler getItemHandler() {
|
||||||
return e -> {
|
return e -> {
|
||||||
Optional<Block> block = e.getClickedBlock();
|
Optional<Block> block = e.getClickedBlock();
|
||||||
|
|
||||||
@ -151,8 +148,7 @@ public class GoldPan extends SimpleSlimefunItem<ItemUseHandler> implements Recip
|
|||||||
*
|
*
|
||||||
* @return the {@link EntityInteractHandler} of this {@link SlimefunItem}
|
* @return the {@link EntityInteractHandler} of this {@link SlimefunItem}
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
public @Nonnull EntityInteractHandler onEntityInteract() {
|
||||||
public EntityInteractHandler onEntityInteract() {
|
|
||||||
return (e, item, offHand) -> {
|
return (e, item, offHand) -> {
|
||||||
if (!(e.getRightClicked() instanceof ItemFrame)) {
|
if (!(e.getRightClicked() instanceof ItemFrame)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
@ -160,9 +156,8 @@ public class GoldPan extends SimpleSlimefunItem<ItemUseHandler> implements Recip
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getDisplayRecipes() {
|
public @Nonnull List<ItemStack> getDisplayRecipes() {
|
||||||
List<ItemStack> recipes = new LinkedList<>();
|
List<ItemStack> recipes = new LinkedList<>();
|
||||||
|
|
||||||
for (GoldPanDrop drop : drops) {
|
for (GoldPanDrop drop : drops) {
|
||||||
|
@ -2,6 +2,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.tools;
|
|||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
@ -22,6 +23,7 @@ import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.listeners.GrapplingHookListener;
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.GrapplingHookListener;
|
||||||
|
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
@ -51,7 +53,7 @@ public class GrapplingHook extends SimpleSlimefunItem<ItemUseHandler> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemUseHandler getItemHandler() {
|
public @Nonnull ItemUseHandler getItemHandler() {
|
||||||
return e -> {
|
return e -> {
|
||||||
Player p = e.getPlayer();
|
Player p = e.getPlayer();
|
||||||
UUID uuid = p.getUniqueId();
|
UUID uuid = p.getUniqueId();
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package io.github.thebusybiscuit.slimefun4.implementation.items.tools;
|
package io.github.thebusybiscuit.slimefun4.implementation.items.tools;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -10,6 +11,7 @@ import io.github.thebusybiscuit.slimefun4.core.handlers.ToolUseHandler;
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag;
|
import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag;
|
||||||
|
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||||
@ -22,7 +24,7 @@ public class HerculesPickaxe extends SimpleSlimefunItem<ToolUseHandler> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ToolUseHandler getItemHandler() {
|
public @Nonnull ToolUseHandler getItemHandler() {
|
||||||
return (e, tool, fortune, drops) -> {
|
return (e, tool, fortune, drops) -> {
|
||||||
if (SlimefunTag.ORES.isTagged(e.getBlock().getType())) {
|
if (SlimefunTag.ORES.isTagged(e.getBlock().getType())) {
|
||||||
if (e.getBlock().getType() == Material.IRON_ORE) {
|
if (e.getBlock().getType() == Material.IRON_ORE) {
|
||||||
|
@ -17,6 +17,7 @@ import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag;
|
import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag;
|
||||||
|
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||||
@ -39,7 +40,7 @@ public class PickaxeOfTheSeeker extends SimpleSlimefunItem<ItemUseHandler> imple
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemUseHandler getItemHandler() {
|
public @Nonnull ItemUseHandler getItemHandler() {
|
||||||
return e -> {
|
return e -> {
|
||||||
Player p = e.getPlayer();
|
Player p = e.getPlayer();
|
||||||
Block closest = findClosestOre(p);
|
Block closest = findClosestOre(p);
|
||||||
@ -69,8 +70,7 @@ public class PickaxeOfTheSeeker extends SimpleSlimefunItem<ItemUseHandler> imple
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
private @Nullable Block findClosestOre(@Nonnull Player p) {
|
||||||
private Block findClosestOre(@Nonnull Player p) {
|
|
||||||
Block start = p.getLocation().getBlock();
|
Block start = p.getLocation().getBlock();
|
||||||
Block closest = null;
|
Block closest = null;
|
||||||
double lastDistance = Double.MAX_VALUE;
|
double lastDistance = Double.MAX_VALUE;
|
||||||
|
@ -2,6 +2,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.tools;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
import org.bukkit.Effect;
|
import org.bukkit.Effect;
|
||||||
@ -20,6 +21,7 @@ import io.github.thebusybiscuit.slimefun4.core.handlers.ToolUseHandler;
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag;
|
import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag;
|
||||||
|
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||||
@ -43,7 +45,7 @@ public class PickaxeOfVeinMining extends SimpleSlimefunItem<ToolUseHandler> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ToolUseHandler getItemHandler() {
|
public @Nonnull ToolUseHandler getItemHandler() {
|
||||||
return (e, tool, fortune, drops) -> {
|
return (e, tool, fortune, drops) -> {
|
||||||
if (SlimefunTag.PICKAXE_OF_VEIN_MINING_BLOCKS.isTagged(e.getBlock().getType())) {
|
if (SlimefunTag.PICKAXE_OF_VEIN_MINING_BLOCKS.isTagged(e.getBlock().getType())) {
|
||||||
List<Block> blocks = Vein.find(e.getBlock(), maxBlocks.getValue(), b -> SlimefunTag.PICKAXE_OF_VEIN_MINING_BLOCKS.isTagged(b.getType()));
|
List<Block> blocks = Vein.find(e.getBlock(), maxBlocks.getValue(), b -> SlimefunTag.PICKAXE_OF_VEIN_MINING_BLOCKS.isTagged(b.getType()));
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package io.github.thebusybiscuit.slimefun4.implementation.items.tools;
|
package io.github.thebusybiscuit.slimefun4.implementation.items.tools;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
@ -10,6 +11,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable;
|
import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;
|
import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
||||||
|
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||||
@ -29,7 +31,7 @@ public class PortableCrafter extends SimpleSlimefunItem<ItemUseHandler> implemen
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemUseHandler getItemHandler() {
|
public @Nonnull ItemUseHandler getItemHandler() {
|
||||||
return e -> {
|
return e -> {
|
||||||
e.cancel();
|
e.cancel();
|
||||||
|
|
||||||
|
@ -1,20 +1,32 @@
|
|||||||
package io.github.thebusybiscuit.slimefun4.implementation.items.tools;
|
package io.github.thebusybiscuit.slimefun4.implementation.items.tools;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable;
|
import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;
|
import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
||||||
|
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link PortableDustbin} is one of the oldest items in Slimefun.
|
||||||
|
* It simply opens an empty {@link Inventory} in which you can dump any
|
||||||
|
* unwanted {@link ItemStack}. When closing the {@link Inventory}, all items
|
||||||
|
* will be voided.
|
||||||
|
*
|
||||||
|
* @author TheBusyBiscuit
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class PortableDustbin extends SimpleSlimefunItem<ItemUseHandler> implements NotPlaceable {
|
public class PortableDustbin extends SimpleSlimefunItem<ItemUseHandler> implements NotPlaceable {
|
||||||
|
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
@ -23,7 +35,7 @@ public class PortableDustbin extends SimpleSlimefunItem<ItemUseHandler> implemen
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemUseHandler getItemHandler() {
|
public @Nonnull ItemUseHandler getItemHandler() {
|
||||||
return e -> {
|
return e -> {
|
||||||
e.cancel();
|
e.cancel();
|
||||||
|
|
||||||
|
@ -3,10 +3,10 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.tools;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
import org.bukkit.Effect;
|
import org.bukkit.Effect;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
@ -15,6 +15,7 @@ import io.github.thebusybiscuit.slimefun4.core.handlers.ToolUseHandler;
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag;
|
import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag;
|
||||||
|
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||||
@ -34,7 +35,7 @@ public class SmeltersPickaxe extends SimpleSlimefunItem<ToolUseHandler> implemen
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ToolUseHandler getItemHandler() {
|
public @Nonnull ToolUseHandler getItemHandler() {
|
||||||
return (e, tool, fortune, drops) -> {
|
return (e, tool, fortune, drops) -> {
|
||||||
Block b = e.getBlock();
|
Block b = e.getBlock();
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable;
|
|||||||
import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;
|
import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
||||||
|
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||||
@ -45,7 +46,7 @@ public class TapeMeasure extends SimpleSlimefunItem<ItemUseHandler> implements N
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemUseHandler getItemHandler() {
|
public @Nonnull ItemUseHandler getItemHandler() {
|
||||||
return e -> {
|
return e -> {
|
||||||
e.cancel();
|
e.cancel();
|
||||||
|
|
||||||
@ -90,9 +91,8 @@ public class TapeMeasure extends SimpleSlimefunItem<ItemUseHandler> implements N
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
public Optional<Location> getAnchor(Player p, ItemStack item) {
|
public @Nonnull Optional<Location> getAnchor(Player p, ItemStack item) {
|
||||||
ItemMeta meta = item.getItemMeta();
|
ItemMeta meta = item.getItemMeta();
|
||||||
|
|
||||||
String data = meta.getPersistentDataContainer().get(key, PersistentDataType.STRING);
|
String data = meta.getPersistentDataContainer().get(key, PersistentDataType.STRING);
|
||||||
@ -119,7 +119,7 @@ public class TapeMeasure extends SimpleSlimefunItem<ItemUseHandler> implements N
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
public OptionalDouble getDistance(Player p, ItemStack item, Block block) {
|
public @Nonnull OptionalDouble getDistance(Player p, ItemStack item, Block block) {
|
||||||
Optional<Location> anchor = getAnchor(p, item);
|
Optional<Location> anchor = getAnchor(p, item);
|
||||||
|
|
||||||
if (anchor.isPresent()) {
|
if (anchor.isPresent()) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package io.github.thebusybiscuit.slimefun4.implementation.listeners;
|
package io.github.thebusybiscuit.slimefun4.implementation.listeners;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.EnumSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ public class DebugFishListener implements Listener {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Read applicable Slimefun tags
|
// Read applicable Slimefun tags
|
||||||
Set<SlimefunTag> tags = new HashSet<>();
|
Set<SlimefunTag> tags = EnumSet.noneOf(SlimefunTag.class);
|
||||||
|
|
||||||
for (SlimefunTag tag : SlimefunTag.values()) {
|
for (SlimefunTag tag : SlimefunTag.values()) {
|
||||||
if (tag.isTagged(b.getType())) {
|
if (tag.isTagged(b.getType())) {
|
||||||
|
@ -19,6 +19,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.elevator.Elevator
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.teleporter.AbstractTeleporterPlate;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.teleporter.AbstractTeleporterPlate;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.teleporter.Teleporter;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.teleporter.Teleporter;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.teleporter.TeleporterPylon;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.teleporter.TeleporterPylon;
|
||||||
|
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||||
|
|
||||||
@ -26,13 +27,19 @@ import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
|||||||
* This {@link Listener} is responsible for the {@link Teleporter} (and {@link ElevatorPlate}).
|
* This {@link Listener} is responsible for the {@link Teleporter} (and {@link ElevatorPlate}).
|
||||||
*
|
*
|
||||||
* @author TheBusyBiscuit
|
* @author TheBusyBiscuit
|
||||||
|
* @author Walshy
|
||||||
* @author Sfiguz7
|
* @author Sfiguz7
|
||||||
* @author SoSeDiK
|
* @author SoSeDiK
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class TeleporterListener implements Listener {
|
public class TeleporterListener implements Listener {
|
||||||
|
|
||||||
private final BlockFace[] faces = { BlockFace.NORTH, BlockFace.NORTH_EAST, BlockFace.EAST, BlockFace.SOUTH_EAST, BlockFace.SOUTH, BlockFace.SOUTH_WEST, BlockFace.WEST, BlockFace.NORTH_WEST };
|
// @formatter:off
|
||||||
|
private final BlockFace[] faces = {
|
||||||
|
BlockFace.NORTH, BlockFace.NORTH_EAST, BlockFace.EAST, BlockFace.SOUTH_EAST,
|
||||||
|
BlockFace.SOUTH, BlockFace.SOUTH_WEST, BlockFace.WEST, BlockFace.NORTH_WEST
|
||||||
|
};
|
||||||
|
// @formatter:on
|
||||||
|
|
||||||
public TeleporterListener(@Nonnull SlimefunPlugin plugin) {
|
public TeleporterListener(@Nonnull SlimefunPlugin plugin) {
|
||||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||||
@ -48,6 +55,11 @@ public class TeleporterListener implements Listener {
|
|||||||
SlimefunItem item = BlockStorage.check(b);
|
SlimefunItem item = BlockStorage.check(b);
|
||||||
Player p = e.getPlayer();
|
Player p = e.getPlayer();
|
||||||
|
|
||||||
|
// Fixes #2966 - Check if Players can use these
|
||||||
|
if (item == null || !item.canUse(p, true)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (item instanceof ElevatorPlate) {
|
if (item instanceof ElevatorPlate) {
|
||||||
// Pressure plate was an elevator
|
// Pressure plate was an elevator
|
||||||
ElevatorPlate elevator = SlimefunItems.ELEVATOR_PLATE.getItem(ElevatorPlate.class);
|
ElevatorPlate elevator = SlimefunItems.ELEVATOR_PLATE.getItem(ElevatorPlate.class);
|
||||||
@ -59,7 +71,7 @@ public class TeleporterListener implements Listener {
|
|||||||
if (teleporter instanceof Teleporter && checkForPylons(b.getRelative(BlockFace.DOWN))) {
|
if (teleporter instanceof Teleporter && checkForPylons(b.getRelative(BlockFace.DOWN))) {
|
||||||
Block block = b.getRelative(BlockFace.DOWN);
|
Block block = b.getRelative(BlockFace.DOWN);
|
||||||
UUID owner = UUID.fromString(BlockStorage.getLocationInfo(block.getLocation(), "owner"));
|
UUID owner = UUID.fromString(BlockStorage.getLocationInfo(block.getLocation(), "owner"));
|
||||||
SlimefunPlugin.getGPSNetwork().getTeleportationManager().openTeleporterGUI(p, owner, block);
|
SlimefunPlugin.getGPSNetwork().getTeleportationManager().openTeleporterGUI(p, owner, block, SlimefunPlugin.getGPSNetwork().getNetworkComplexity(owner));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user