mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
Super extreme ultra mega refactor 3000
This commit is contained in:
parent
9f07d6b8c1
commit
4882c7e4cc
@ -39,6 +39,8 @@
|
||||
* Removed Solar Array
|
||||
* A lot of internal cleanup
|
||||
* Performance improvements for GEO Miner and Oil Pump
|
||||
* General performance improvements
|
||||
* Changed Startup console message
|
||||
|
||||
### Fixes
|
||||
* Fixed #1355
|
||||
|
4
pom.xml
4
pom.xml
@ -109,13 +109,13 @@
|
||||
<dependency>
|
||||
<groupId>com.github.TheBusyBiscuit</groupId>
|
||||
<artifactId>CS-CoreLib</artifactId>
|
||||
<version>ebba7c0096</version>
|
||||
<version>8081bb4fe4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.thebusybiscuit</groupId>
|
||||
<artifactId>CS-CoreLib2</artifactId>
|
||||
<version>0.8.8</version>
|
||||
<version>0.9</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -76,7 +76,7 @@ public class ErrorReport {
|
||||
Slimefun.getLogger().log(Level.WARNING, "You can put the file on Pastebin and then post it here: https://github.com/TheBusyBiscuit/Slimefun4/issues");
|
||||
Slimefun.getLogger().log(Level.WARNING, "");
|
||||
} catch (FileNotFoundException x) {
|
||||
Slimefun.getLogger().log(Level.SEVERE, "An Error occured while saving an Error-Report for Slimefun " + Slimefun.getVersion(), x);
|
||||
Slimefun.getLogger().log(Level.SEVERE, "An Error occured while saving an Error-Report for Slimefun " + SlimefunPlugin.getVersion(), x);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -0,0 +1,134 @@
|
||||
package io.github.thebusybiscuit.slimefun4.api.events;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.data.ComputedOptional;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||
|
||||
public class ItemUseEvent extends Event {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private final PlayerInteractEvent event;
|
||||
private final Player player;
|
||||
|
||||
private final Optional<ItemStack> itemStack;
|
||||
private final Optional<Block> clickedBlock;
|
||||
|
||||
private final EquipmentSlot hand;
|
||||
private final BlockFace face;
|
||||
|
||||
private ComputedOptional<SlimefunItem> slimefunItem = ComputedOptional.createNew();
|
||||
private ComputedOptional<SlimefunItem> slimefunBlock = ComputedOptional.createNew();
|
||||
|
||||
private Result itemResult = Result.DEFAULT;
|
||||
private Result blockResult = Result.DEFAULT;
|
||||
|
||||
public ItemUseEvent(PlayerInteractEvent e) {
|
||||
event = e;
|
||||
player = e.getPlayer();
|
||||
clickedBlock = Optional.ofNullable(e.getClickedBlock());
|
||||
face = e.getBlockFace();
|
||||
hand = e.getHand();
|
||||
|
||||
if (e.getItem() == null || e.getItem().getType() == Material.AIR || e.getItem().getAmount() == 0) {
|
||||
itemStack = Optional.empty();
|
||||
}
|
||||
else {
|
||||
itemStack = Optional.of(e.getItem());
|
||||
}
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public PlayerInteractEvent getInteractEvent() {
|
||||
return event;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public ItemStack getItem() {
|
||||
return itemStack.orElse(new ItemStack(Material.AIR));
|
||||
}
|
||||
|
||||
public EquipmentSlot getHand() {
|
||||
return hand;
|
||||
}
|
||||
|
||||
public Optional<Block> getClickedBlock() {
|
||||
return clickedBlock;
|
||||
}
|
||||
|
||||
public BlockFace getClickedFace() {
|
||||
return face;
|
||||
}
|
||||
|
||||
public Optional<SlimefunItem> getSlimefunItem() {
|
||||
|
||||
if (!slimefunItem.isComputed()) {
|
||||
if (itemStack.isPresent()) {
|
||||
slimefunItem.compute(SlimefunItem.getByItem(itemStack.get()));
|
||||
}
|
||||
else {
|
||||
slimefunItem = ComputedOptional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
return slimefunItem.getAsOptional();
|
||||
}
|
||||
|
||||
public Optional<SlimefunItem> getSlimefunBlock() {
|
||||
|
||||
if (!slimefunBlock.isComputed()) {
|
||||
if (clickedBlock.isPresent()) {
|
||||
slimefunBlock.compute(BlockStorage.check(clickedBlock.get()));
|
||||
}
|
||||
else {
|
||||
slimefunBlock = ComputedOptional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
return slimefunBlock.getAsOptional();
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
itemResult = Result.DENY;
|
||||
blockResult = Result.DENY;
|
||||
}
|
||||
|
||||
public Result useItem() {
|
||||
return itemResult;
|
||||
}
|
||||
|
||||
public Result useBlock() {
|
||||
return blockResult;
|
||||
}
|
||||
|
||||
public void setUseItem(Result result) {
|
||||
itemResult = result;
|
||||
}
|
||||
|
||||
public void setUseBlock(Result result) {
|
||||
blockResult = result;
|
||||
}
|
||||
|
||||
}
|
@ -14,6 +14,10 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||
|
||||
public class GiveCommand extends SubCommand {
|
||||
|
||||
private static final String PLACEHOLDER_PLAYER = "%player%";
|
||||
private static final String PLACEHOLDER_ITEM = "%item%";
|
||||
private static final String PLACEHOLDER_AMOUNT = "%amount%";
|
||||
|
||||
public GiveCommand(SlimefunPlugin plugin, SlimefunCommand cmd) {
|
||||
super(plugin, cmd);
|
||||
@ -32,37 +36,39 @@ public class GiveCommand extends SubCommand {
|
||||
|
||||
if (player.isPresent()) {
|
||||
Player p = player.get();
|
||||
|
||||
if (Slimefun.listIDs().contains(args[2].toUpperCase())) {
|
||||
SlimefunPlugin.getLocal().sendMessage(p, "messages.given-item", true, msg -> msg.replace("%item%", SlimefunItem.getByID(args[2].toUpperCase()).getItem().getItemMeta().getDisplayName()).replace("%amount%", "1"));
|
||||
SlimefunPlugin.getLocal().sendMessage(p, "messages.given-item", true, msg -> msg.replace(PLACEHOLDER_ITEM, SlimefunItem.getByID(args[2].toUpperCase()).getItem().getItemMeta().getDisplayName()).replace(PLACEHOLDER_AMOUNT, "1"));
|
||||
p.getInventory().addItem(SlimefunItem.getByID(args[2].toUpperCase()).getItem());
|
||||
SlimefunPlugin.getLocal().sendMessage(sender, "messages.give-item", true, msg -> msg.replace("%player%", args[1]).replace("%item%", SlimefunItem.getByID(args[2].toUpperCase()).getItem().getItemMeta().getDisplayName()).replace("%amount%", "1"));
|
||||
SlimefunPlugin.getLocal().sendMessage(sender, "messages.give-item", true, msg -> msg.replace(PLACEHOLDER_PLAYER, args[1]).replace(PLACEHOLDER_ITEM, SlimefunItem.getByID(args[2].toUpperCase()).getItem().getItemMeta().getDisplayName()).replace(PLACEHOLDER_AMOUNT, "1"));
|
||||
}
|
||||
else SlimefunPlugin.getLocal().sendMessage(sender, "messages.not-valid-item", true, msg -> msg.replace("%item%", args[2]));
|
||||
else SlimefunPlugin.getLocal().sendMessage(sender, "messages.not-valid-item", true, msg -> msg.replace(PLACEHOLDER_ITEM, args[2]));
|
||||
}
|
||||
else SlimefunPlugin.getLocal().sendMessage(sender, "messages.not-online", true, msg -> msg.replace("%player%", args[1]));
|
||||
else SlimefunPlugin.getLocal().sendMessage(sender, "messages.not-online", true, msg -> msg.replace(PLACEHOLDER_PLAYER, args[1]));
|
||||
}
|
||||
else if (args.length == 4) {
|
||||
Optional<Player> player = PlayerList.findByName(args[1]);
|
||||
|
||||
if (player.isPresent()) {
|
||||
Player p = player.get();
|
||||
|
||||
if (Slimefun.listIDs().contains(args[2].toUpperCase())) {
|
||||
try {
|
||||
int amount = Integer.parseInt(args[3]);
|
||||
|
||||
if (amount > 0) {
|
||||
SlimefunPlugin.getLocal().sendMessage(p, "messages.given-item", true, msg -> msg.replace("%item%", SlimefunItem.getByID(args[2].toUpperCase()).getItem().getItemMeta().getDisplayName()).replace("%amount%", String.valueOf(amount)));
|
||||
SlimefunPlugin.getLocal().sendMessage(p, "messages.given-item", true, msg -> msg.replace(PLACEHOLDER_ITEM, SlimefunItem.getByID(args[2].toUpperCase()).getItem().getItemMeta().getDisplayName()).replace(PLACEHOLDER_AMOUNT, String.valueOf(amount)));
|
||||
p.getInventory().addItem(new CustomItem(SlimefunItem.getByID(args[2].toUpperCase()).getItem(), amount));
|
||||
SlimefunPlugin.getLocal().sendMessage(sender, "messages.give-item", true, msg -> msg.replace("%player%", args[1]).replace("%item%", SlimefunItem.getByID(args[2].toUpperCase()).getItem().getItemMeta().getDisplayName()).replace("%amount%", String.valueOf(amount)));
|
||||
SlimefunPlugin.getLocal().sendMessage(sender, "messages.give-item", true, msg -> msg.replace(PLACEHOLDER_PLAYER, args[1]).replace(PLACEHOLDER_ITEM, SlimefunItem.getByID(args[2].toUpperCase()).getItem().getItemMeta().getDisplayName()).replace(PLACEHOLDER_AMOUNT, String.valueOf(amount)));
|
||||
}
|
||||
else SlimefunPlugin.getLocal().sendMessage(sender, "messages.not-valid-amount", true, msg -> msg.replace("%amount%", String.valueOf(amount)));
|
||||
else SlimefunPlugin.getLocal().sendMessage(sender, "messages.not-valid-amount", true, msg -> msg.replace(PLACEHOLDER_AMOUNT, String.valueOf(amount)));
|
||||
} catch (NumberFormatException e){
|
||||
SlimefunPlugin.getLocal().sendMessage(sender, "messages.not-valid-amount", true, msg -> msg.replace("%amount%", args[3]));
|
||||
SlimefunPlugin.getLocal().sendMessage(sender, "messages.not-valid-amount", true, msg -> msg.replace(PLACEHOLDER_AMOUNT, args[3]));
|
||||
}
|
||||
}
|
||||
else SlimefunPlugin.getLocal().sendMessage(sender, "messages.not-valid-item", true, msg -> msg.replace("%item%", args[2]));
|
||||
else SlimefunPlugin.getLocal().sendMessage(sender, "messages.not-valid-item", true, msg -> msg.replace(PLACEHOLDER_ITEM, args[2]));
|
||||
}
|
||||
else SlimefunPlugin.getLocal().sendMessage(sender, "messages.not-online", true, msg -> msg.replace("%player%", args[1]));
|
||||
else SlimefunPlugin.getLocal().sendMessage(sender, "messages.not-online", true, msg -> msg.replace(PLACEHOLDER_PLAYER, args[1]));
|
||||
}
|
||||
else SlimefunPlugin.getLocal().sendMessage(sender, "messages.usage", true, msg -> msg.replace("%usage%", "/sf give <Player> <Slimefun Item> [Amount]"));
|
||||
}
|
||||
|
@ -13,6 +13,9 @@ import me.mrCookieSlime.Slimefun.Objects.Research;
|
||||
import me.mrCookieSlime.Slimefun.api.PlayerProfile;
|
||||
|
||||
public class ResearchCommand extends SubCommand {
|
||||
|
||||
private static final String PLACEHOLDER_PLAYER = "%player%";
|
||||
private static final String PLACEHOLDER_RESEARCH = "%research%";
|
||||
|
||||
public ResearchCommand(SlimefunPlugin plugin, SlimefunCommand cmd) {
|
||||
super(plugin, cmd);
|
||||
@ -40,7 +43,7 @@ public class ResearchCommand extends SubCommand {
|
||||
PlayerProfile.get(p, profile -> {
|
||||
if (args[2].equalsIgnoreCase("all")) {
|
||||
for (Research res : Research.list()) {
|
||||
if (!profile.hasUnlocked(res)) SlimefunPlugin.getLocal().sendMessage(sender, "messages.give-research", true, msg -> msg.replace("%player%", p.getName()).replace("%research%", res.getName()));
|
||||
if (!profile.hasUnlocked(res)) SlimefunPlugin.getLocal().sendMessage(sender, "messages.give-research", true, msg -> msg.replace(PLACEHOLDER_PLAYER, p.getName()).replace(PLACEHOLDER_RESEARCH, res.getName()));
|
||||
res.unlock(p, true);
|
||||
}
|
||||
}
|
||||
@ -48,7 +51,7 @@ public class ResearchCommand extends SubCommand {
|
||||
for (Research res : Research.list()) {
|
||||
profile.setResearched(res, false);
|
||||
}
|
||||
SlimefunPlugin.getLocal().sendMessage(p, "commands.research.reset", true, msg -> msg.replace("%player%", args[1]));
|
||||
SlimefunPlugin.getLocal().sendMessage(p, "commands.research.reset", true, msg -> msg.replace(PLACEHOLDER_PLAYER, args[1]));
|
||||
}
|
||||
else {
|
||||
Research research = null;
|
||||
@ -62,16 +65,16 @@ public class ResearchCommand extends SubCommand {
|
||||
if (research != null) {
|
||||
research.unlock(p, true);
|
||||
final Research r = research;
|
||||
SlimefunPlugin.getLocal().sendMessage(sender, "messages.give-research", true, msg -> msg.replace("%player%", p.getName()).replace("%research%", r.getName()));
|
||||
SlimefunPlugin.getLocal().sendMessage(sender, "messages.give-research", true, msg -> msg.replace(PLACEHOLDER_PLAYER, p.getName()).replace(PLACEHOLDER_RESEARCH, r.getName()));
|
||||
}
|
||||
else {
|
||||
SlimefunPlugin.getLocal().sendMessage(sender, "messages.not-valid-research", true, msg -> msg.replace("%research%", args[2]));
|
||||
SlimefunPlugin.getLocal().sendMessage(sender, "messages.not-valid-research", true, msg -> msg.replace(PLACEHOLDER_RESEARCH, args[2]));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
SlimefunPlugin.getLocal().sendMessage(sender, "messages.not-online", true, msg -> msg.replace("%player%", args[1]));
|
||||
SlimefunPlugin.getLocal().sendMessage(sender, "messages.not-online", true, msg -> msg.replace(PLACEHOLDER_PLAYER, args[1]));
|
||||
}
|
||||
}
|
||||
else SlimefunPlugin.getLocal().sendMessage(sender, "messages.no-permission", true);
|
||||
|
@ -9,7 +9,6 @@ import org.bukkit.entity.Player;
|
||||
import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
|
||||
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||
|
||||
public class TeleporterCommand extends SubCommand {
|
||||
|
||||
@ -21,8 +20,7 @@ public class TeleporterCommand extends SubCommand {
|
||||
public String getName() {
|
||||
return "teleporter";
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
||||
@Override
|
||||
public void onExecute(CommandSender sender, String[] args) {
|
||||
if (args.length == 2) {
|
||||
@ -30,7 +28,7 @@ public class TeleporterCommand extends SubCommand {
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(args[1]);
|
||||
|
||||
if (player.getName() != null) {
|
||||
Slimefun.getGPSNetwork().openTeleporterGUI((Player) sender, player.getUniqueId(), ((Player) sender).getLocation().getBlock().getRelative(BlockFace.DOWN), 999999999);
|
||||
SlimefunPlugin.getGPSNetwork().openTeleporterGUI((Player) sender, player.getUniqueId(), ((Player) sender).getLocation().getBlock().getRelative(BlockFace.DOWN), 999999999);
|
||||
}
|
||||
else SlimefunPlugin.getLocal().sendMessage(sender, "messages.unknown-player", msg -> msg.replace("%player%", args[1]));
|
||||
}
|
||||
|
@ -371,21 +371,15 @@ public class ChestSlimefunGuide implements ISlimefunGuide {
|
||||
|
||||
RecipeChoice[] choices = SlimefunPlugin.getMinecraftRecipes().getRecipeInput(recipe);
|
||||
|
||||
if (choices.length == 1) {
|
||||
recipeItems[4] = choices[0].getItemStack();
|
||||
|
||||
if (choices[0] instanceof MaterialChoice && ((MaterialChoice) choices[0]).getChoices().size() > 1) {
|
||||
task.add(RECIPE_SLOTS[4], (MaterialChoice) choices[0]);
|
||||
}
|
||||
if (choices[0] instanceof MaterialChoice && ((MaterialChoice) choices[0]).getChoices().size() > 1) {
|
||||
recipeItems[4] = new ItemStack(((MaterialChoice) choices[0]).getChoices().get(0));
|
||||
task.add(RECIPE_SLOTS[4], (MaterialChoice) choices[0]);
|
||||
}
|
||||
else {
|
||||
for (int i = 0; i < choices.length; i++) {
|
||||
if (choices[i] != null) {
|
||||
recipeItems[i] = choices[i].getItemStack();
|
||||
|
||||
if (choices[i] instanceof MaterialChoice && ((MaterialChoice) choices[i]).getChoices().size() > 1) {
|
||||
task.add(RECIPE_SLOTS[i], (MaterialChoice) choices[i]);
|
||||
}
|
||||
if (choices[i] instanceof MaterialChoice && ((MaterialChoice) choices[i]).getChoices().size() > 1) {
|
||||
recipeItems[i] = new ItemStack(((MaterialChoice) choices[i]).getChoices().get(0));
|
||||
task.add(RECIPE_SLOTS[i], (MaterialChoice) choices[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -161,6 +161,7 @@ public final class GuideSettings {
|
||||
"&7Something will be added here later..."
|
||||
),
|
||||
(pl, slot, item, action) -> {
|
||||
// Add something here
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ public class BlockListener implements Listener {
|
||||
ItemStack item = e.getItemInHand();
|
||||
|
||||
SlimefunItem sfItem = SlimefunItem.getByItem(item);
|
||||
if (sfItem != null && !sfItem.isDisabled() && !(sfItem instanceof NotPlaceable)) {
|
||||
if (sfItem != null && Slimefun.isEnabled(e.getPlayer(), sfItem, true) && !(sfItem instanceof NotPlaceable)) {
|
||||
if (!Slimefun.hasUnlocked(e.getPlayer(), sfItem, true)) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
@ -196,6 +196,7 @@ public class BlockListener implements Listener {
|
||||
int fortune = getFortuneLevel(item, e.getBlock());
|
||||
|
||||
Block block2 = e.getBlock().getRelative(BlockFace.UP);
|
||||
|
||||
if (sensitiveMaterials.contains(block2.getType())) {
|
||||
SlimefunItem sfItem = BlockStorage.check(e.getBlock().getRelative(BlockFace.UP));
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
package io.github.thebusybiscuit.slimefun4.implementation.listeners;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityPickupItemEvent;
|
||||
import org.bukkit.event.inventory.InventoryPickupItemEvent;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
|
||||
/**
|
||||
* Listens to the ItemPickup events to prevent it if the item has the "no_pickup" metadata or is an ALTAR_PROBE.
|
||||
*
|
||||
@ -16,6 +16,9 @@ import org.bukkit.event.inventory.InventoryPickupItemEvent;
|
||||
* @since 4.1.11
|
||||
*/
|
||||
public class ItemPickupListener implements Listener {
|
||||
|
||||
private static final String METADATA_JEY = "no_pickup";
|
||||
private static final String ITEM_PREFIX = ChatColors.color("&5&dALTAR &3Probe - &e");
|
||||
|
||||
public ItemPickupListener(SlimefunPlugin plugin) {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
@ -23,8 +26,8 @@ public class ItemPickupListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPickup(EntityPickupItemEvent e) {
|
||||
if (e.getItem().hasMetadata("no_pickup")) e.setCancelled(true);
|
||||
else if (!e.getItem().hasMetadata("no_pickup") && e.getItem().getItemStack().hasItemMeta() && e.getItem().getItemStack().getItemMeta().hasDisplayName() && e.getItem().getItemStack().getItemMeta().getDisplayName().startsWith(ChatColor.translateAlternateColorCodes('&', "&5&dALTAR &3Probe - &e"))) {
|
||||
if (e.getItem().hasMetadata(METADATA_JEY)) e.setCancelled(true);
|
||||
else if (e.getItem().getItemStack().hasItemMeta() && e.getItem().getItemStack().getItemMeta().hasDisplayName() && e.getItem().getItemStack().getItemMeta().getDisplayName().startsWith(ITEM_PREFIX)) {
|
||||
e.setCancelled(true);
|
||||
e.getItem().remove();
|
||||
}
|
||||
@ -32,8 +35,8 @@ public class ItemPickupListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onMinecartPickup(InventoryPickupItemEvent e) {
|
||||
if (e.getItem().hasMetadata("no_pickup")) e.setCancelled(true);
|
||||
else if (!e.getItem().hasMetadata("no_pickup") && e.getItem().getItemStack().hasItemMeta() && e.getItem().getItemStack().getItemMeta().hasDisplayName() && e.getItem().getItemStack().getItemMeta().getDisplayName().startsWith(ChatColor.translateAlternateColorCodes('&', "&5&dALTAR &3Probe - &e"))) {
|
||||
if (e.getItem().hasMetadata(METADATA_JEY)) e.setCancelled(true);
|
||||
else if (e.getItem().getItemStack().hasItemMeta() && e.getItem().getItemStack().getItemMeta().hasDisplayName() && e.getItem().getItemStack().getItemMeta().getDisplayName().startsWith(ITEM_PREFIX)) {
|
||||
e.setCancelled(true);
|
||||
e.getItem().remove();
|
||||
}
|
||||
|
@ -3,21 +3,28 @@ package io.github.thebusybiscuit.slimefun4.implementation.listeners;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.GuideSettings;
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunGuide;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;
|
||||
|
||||
public class SlimefunGuideListener implements Listener {
|
||||
|
||||
private final boolean giveOnFirstJoin;
|
||||
|
||||
public SlimefunGuideListener(SlimefunPlugin plugin) {
|
||||
public SlimefunGuideListener(SlimefunPlugin plugin, boolean giveOnFirstJoin) {
|
||||
this.giveOnFirstJoin = giveOnFirstJoin;
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent e) {
|
||||
if (!e.getPlayer().hasPlayedBefore()) {
|
||||
if (giveOnFirstJoin && !e.getPlayer().hasPlayedBefore()) {
|
||||
Player p = e.getPlayer();
|
||||
if (!SlimefunPlugin.getWhitelist().getBoolean(p.getWorld().getName() + ".enabled")) return;
|
||||
if (!SlimefunPlugin.getWhitelist().getBoolean(p.getWorld().getName() + ".enabled-items.SLIMEFUN_GUIDE")) return;
|
||||
@ -26,5 +33,28 @@ public class SlimefunGuideListener implements Listener {
|
||||
p.getInventory().addItem(SlimefunGuide.getItem(type));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
ItemStack item = e.getItem();
|
||||
|
||||
if (SlimefunManager.isItemSimilar(item, SlimefunGuide.getItem(SlimefunGuideLayout.BOOK), true)) {
|
||||
if (p.isSneaking()) GuideSettings.openSettings(p, item);
|
||||
else SlimefunGuide.openGuide(p, SlimefunGuideLayout.BOOK);
|
||||
}
|
||||
else if (SlimefunManager.isItemSimilar(item, SlimefunGuide.getItem(SlimefunGuideLayout.CHEST), true)) {
|
||||
if (p.isSneaking()) GuideSettings.openSettings(p, item);
|
||||
else SlimefunGuide.openGuide(p, SlimefunGuideLayout.CHEST);
|
||||
}
|
||||
else if (SlimefunManager.isItemSimilar(item, SlimefunGuide.getItem(SlimefunGuideLayout.CHEAT_SHEET), true)) {
|
||||
if (p.isSneaking()) GuideSettings.openSettings(p, item);
|
||||
else {
|
||||
// We rather just run the command here,
|
||||
// all necessary permission checks will be handled there.
|
||||
p.chat("/sf cheat");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package io.github.thebusybiscuit.slimefun4.implementation.listeners;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -8,6 +9,7 @@ import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.IronGolem;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event.Result;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -23,20 +25,18 @@ import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.GuideSettings;
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.events.ItemUseEvent;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunGuide;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.Juice;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.MultiTool;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunBackpack;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockUseHandler;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemConsumptionHandler;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemDropHandler;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemHandler;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemInteractionHandler;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemUseHandler;
|
||||
import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;
|
||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||
@ -54,19 +54,39 @@ public class SlimefunItemListener implements Listener {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
utilities = SlimefunPlugin.getUtilities();
|
||||
}
|
||||
|
||||
/*
|
||||
* Handles Left click use and checks for disabled items.
|
||||
*/
|
||||
|
||||
@EventHandler
|
||||
public void enabledCheck(PlayerInteractEvent e) {
|
||||
if (e.getAction() != Action.LEFT_CLICK_AIR && e.getAction() != Action.LEFT_CLICK_BLOCK) {
|
||||
return;
|
||||
}
|
||||
public void onRightClick(PlayerInteractEvent e) {
|
||||
if (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
io.github.thebusybiscuit.slimefun4.api.events.ItemUseEvent event = new io.github.thebusybiscuit.slimefun4.api.events.ItemUseEvent(e);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
boolean itemUsed = e.getHand() == EquipmentSlot.HAND;
|
||||
|
||||
if (event.useItem() != Result.DENY) {
|
||||
Optional<SlimefunItem> optional = event.getSlimefunItem();
|
||||
|
||||
if (optional.isPresent() && Slimefun.hasUnlocked(e.getPlayer(), optional.get(), true)) {
|
||||
optional.get().callItemHandler(ItemUseHandler.class, handler -> handler.onRightClick(event));
|
||||
itemUsed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!itemUsed && event.useBlock() != Result.DENY) {
|
||||
Optional<SlimefunItem> optional = event.getSlimefunBlock();
|
||||
|
||||
ItemStack item = e.getItem();
|
||||
if (item != null && !Slimefun.isEnabled(e.getPlayer(), item, true)) {
|
||||
e.setCancelled(true);
|
||||
if (optional.isPresent() && Slimefun.hasUnlocked(e.getPlayer(), optional.get(), true)) {
|
||||
optional.get().callItemHandler(BlockUseHandler.class, handler -> handler.onRightClick(event));
|
||||
}
|
||||
}
|
||||
|
||||
if (e.useInteractedBlock() != Result.DENY) {
|
||||
e.setUseInteractedBlock(event.useBlock());
|
||||
}
|
||||
|
||||
if (e.useItemInHand() != Result.DENY) {
|
||||
e.setUseItemInHand(event.useItem());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,22 +99,7 @@ public class SlimefunItemListener implements Listener {
|
||||
Player p = e.getPlayer();
|
||||
ItemStack item = e.getItem();
|
||||
|
||||
if (SlimefunManager.isItemSimilar(item, SlimefunGuide.getItem(SlimefunGuideLayout.BOOK), true)) {
|
||||
if (p.isSneaking()) GuideSettings.openSettings(p, item);
|
||||
else SlimefunGuide.openGuide(p, SlimefunGuideLayout.BOOK);
|
||||
}
|
||||
else if (SlimefunManager.isItemSimilar(item, SlimefunGuide.getItem(SlimefunGuideLayout.CHEST), true)) {
|
||||
if (p.isSneaking()) GuideSettings.openSettings(p, item);
|
||||
else SlimefunGuide.openGuide(p, SlimefunGuideLayout.CHEST);
|
||||
}
|
||||
else if (SlimefunManager.isItemSimilar(item, SlimefunGuide.getItem(SlimefunGuideLayout.CHEAT_SHEET), true)) {
|
||||
if (p.isSneaking()) GuideSettings.openSettings(p, item);
|
||||
else p.chat("/sf cheat");
|
||||
}
|
||||
else if (SlimefunManager.isItemSimilar(item, SlimefunItems.DEBUG_FISH, true)) {
|
||||
// Ignore the debug fish in here
|
||||
}
|
||||
else {
|
||||
if (!SlimefunManager.isItemSimilar(item, SlimefunItems.DEBUG_FISH, true)) {
|
||||
SlimefunItem slimefunItem = SlimefunItem.getByItem(item);
|
||||
|
||||
if (slimefunItem != null) {
|
||||
@ -103,12 +108,7 @@ public class SlimefunItemListener implements Listener {
|
||||
handler.onRightClick(e, p, item)
|
||||
);
|
||||
|
||||
// Open the Backpack (also includes Coolers)
|
||||
if (slimefunItem instanceof SlimefunBackpack) {
|
||||
e.setCancelled(true);
|
||||
BackpackListener.openBackpack(p, item, (SlimefunBackpack) slimefunItem);
|
||||
}
|
||||
else if (slimefunItem instanceof MultiTool) {
|
||||
if (slimefunItem instanceof MultiTool) {
|
||||
e.setCancelled(true);
|
||||
|
||||
List<Integer> modes = ((MultiTool) slimefunItem).getModes();
|
||||
|
@ -7,9 +7,9 @@ import org.bukkit.Color;
|
||||
import org.bukkit.FireworkEffect;
|
||||
import org.bukkit.FireworkEffect.Type;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Firework;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.meta.FireworkMeta;
|
||||
|
||||
public final class FireworkUtils {
|
||||
@ -40,9 +40,9 @@ public final class FireworkUtils {
|
||||
return fw;
|
||||
}
|
||||
|
||||
public static void launchRandom(Player p, int amount) {
|
||||
public static void launchRandom(Entity n, int amount) {
|
||||
for (int i = 0; i < amount; i++) {
|
||||
Location l = p.getLocation().clone();
|
||||
Location l = n.getLocation().clone();
|
||||
l.setX(l.getX() + ThreadLocalRandom.current().nextInt(amount));
|
||||
l.setX(l.getX() - ThreadLocalRandom.current().nextInt(amount));
|
||||
l.setZ(l.getZ() + ThreadLocalRandom.current().nextInt(amount));
|
||||
|
@ -2,11 +2,13 @@ package me.mrCookieSlime.Slimefun.Objects.SlimefunItem;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.listeners.BackpackListener;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemUseHandler;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class SlimefunBackpack extends SlimefunItem {
|
||||
public class SlimefunBackpack extends SimpleSlimefunItem<ItemUseHandler> {
|
||||
|
||||
private final int size;
|
||||
|
||||
@ -20,4 +22,9 @@ public class SlimefunBackpack extends SlimefunItem {
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemUseHandler getItemHandler() {
|
||||
return e -> BackpackListener.openBackpack(e.getPlayer(), e.getItem(), this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,36 @@
|
||||
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.cargo;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockUseHandler;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
import me.mrCookieSlime.Slimefun.api.item_transport.CargoNet;
|
||||
|
||||
public class CargoConnector extends SimpleSlimefunItem<BlockUseHandler> {
|
||||
|
||||
public CargoConnector(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) {
|
||||
super(category, item, recipeType, recipe, recipeOutput);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BlockUseHandler getItemHandler() {
|
||||
return e -> {
|
||||
Player p = e.getPlayer();
|
||||
Block b = e.getClickedBlock().get();
|
||||
|
||||
if (CargoNet.getNetworkFromLocation(b.getLocation()) != null) {
|
||||
p.sendMessage(ChatColors.color("&7Connected: " + "&2\u2714"));
|
||||
}
|
||||
else {
|
||||
p.sendMessage(ChatColors.color("&7Connected: " + "&4\u2718"));
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
@ -1,18 +1,20 @@
|
||||
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.cargo;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.events.ItemUseEvent;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.holograms.SimpleHologram;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.events.ItemUseEvent;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemInteractionHandler;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockUseHandler;
|
||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
import me.mrCookieSlime.Slimefun.api.item_transport.CargoNet;
|
||||
@ -42,26 +44,24 @@ public class CargoManagerBlock extends SlimefunItem {
|
||||
return false;
|
||||
}
|
||||
|
||||
}, new ItemInteractionHandler() {
|
||||
}, new BlockUseHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onRightClick(ItemUseEvent e, Player p, ItemStack stack) {
|
||||
Block b = e.getClickedBlock();
|
||||
if (b == null) return false;
|
||||
|
||||
String item = BlockStorage.checkID(b);
|
||||
if (item == null || !item.equals(getID())) return false;
|
||||
e.setCancelled(true);
|
||||
public void onRightClick(ItemUseEvent e) {
|
||||
Optional<Block> block = e.getClickedBlock();
|
||||
if (block.isPresent()) {
|
||||
Player p = e.getPlayer();
|
||||
Block b = block.get();
|
||||
|
||||
if (BlockStorage.getLocationInfo(b.getLocation(), "visualizer") == null) {
|
||||
BlockStorage.addBlockInfo(b, "visualizer", "disabled");
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cCargo Net Visualizer: " + "&4\u2718"));
|
||||
if (BlockStorage.getLocationInfo(b.getLocation(), "visualizer") == null) {
|
||||
BlockStorage.addBlockInfo(b, "visualizer", "disabled");
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cCargo Net Visualizer: " + "&4\u2718"));
|
||||
}
|
||||
else {
|
||||
BlockStorage.addBlockInfo(b, "visualizer", null);
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cCargo Net Visualizer: " + "&2\u2714"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
BlockStorage.addBlockInfo(b, "visualizer", null);
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cCargo Net Visualizer: " + "&2\u2714"));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -0,0 +1,41 @@
|
||||
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemUseHandler;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class Bandage extends SimpleSlimefunItem<ItemUseHandler> {
|
||||
|
||||
public Bandage(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) {
|
||||
super(category, item, recipeType, recipe, recipeOutput);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemUseHandler getItemHandler() {
|
||||
return e -> {
|
||||
Player p = e.getPlayer();
|
||||
|
||||
if (p.getGameMode() != GameMode.CREATIVE) {
|
||||
ItemUtils.consumeItem(e.getItem(), false);
|
||||
}
|
||||
|
||||
p.getWorld().playEffect(p.getLocation(), Effect.STEP_SOUND, Material.WHITE_WOOL);
|
||||
p.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 1));
|
||||
p.setFireTicks(0);
|
||||
|
||||
e.cancel();
|
||||
};
|
||||
}
|
||||
|
||||
}
|
@ -20,16 +20,11 @@ public class DietCookie extends SimpleSlimefunItem<ItemConsumptionHandler> {
|
||||
@Override
|
||||
public ItemConsumptionHandler getItemHandler() {
|
||||
return (e, p, item) -> {
|
||||
if (isItem(item)) {
|
||||
SlimefunPlugin.getLocal().sendMessage(p, "messages.diet-cookie");
|
||||
p.playSound(p.getLocation(), Sound.ENTITY_GENERIC_EAT, 1, 1);
|
||||
SlimefunPlugin.getLocal().sendMessage(p, "messages.diet-cookie");
|
||||
p.playSound(p.getLocation(), Sound.ENTITY_GENERIC_EAT, 1, 1);
|
||||
|
||||
if (p.hasPotionEffect(PotionEffectType.LEVITATION)) p.removePotionEffect(PotionEffectType.LEVITATION);
|
||||
p.addPotionEffect(PotionEffectType.LEVITATION.createEffect(60, 1));
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
if (p.hasPotionEffect(PotionEffectType.LEVITATION)) p.removePotionEffect(PotionEffectType.LEVITATION);
|
||||
p.addPotionEffect(PotionEffectType.LEVITATION.createEffect(60, 1));
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1,30 +1,28 @@
|
||||
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items;
|
||||
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemInteractionHandler;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemUseHandler;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class EnderBackpack extends SimpleSlimefunItem<ItemInteractionHandler> {
|
||||
public class EnderBackpack extends SimpleSlimefunItem<ItemUseHandler> {
|
||||
|
||||
public EnderBackpack(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, item, recipeType, recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemInteractionHandler getItemHandler() {
|
||||
return (e, p, item) -> {
|
||||
if (isItem(item)) {
|
||||
e.setCancelled(true);
|
||||
p.openInventory(p.getEnderChest());
|
||||
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 1, 1);
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
public ItemUseHandler getItemHandler() {
|
||||
return e -> {
|
||||
Player p = e.getPlayer();
|
||||
p.openInventory(p.getEnderChest());
|
||||
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 1, 1);
|
||||
e.cancel();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -40,47 +40,49 @@ public class ExplosivePickaxe extends SimpleSlimefunItem<BlockBreakHandler> impl
|
||||
public BlockBreakHandler getItemHandler() {
|
||||
return (e, item, fortune, drops) -> {
|
||||
if (isItem(item)) {
|
||||
e.getBlock().getWorld().createExplosion(e.getBlock().getLocation(), 0.0F);
|
||||
e.getBlock().getWorld().playSound(e.getBlock().getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 0.3F, 1F);
|
||||
|
||||
for (int x = -1; x <= 1; x++) {
|
||||
for (int y = -1; y <= 1; y++) {
|
||||
for (int z = -1; z <= 1; z++) {
|
||||
if (x == 0 && y == 0 && z == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Block b = e.getBlock().getRelative(x, y, z);
|
||||
|
||||
if (b.getType() != Material.AIR && !b.isLiquid() && !MaterialCollections.getAllUnbreakableBlocks().contains(b.getType()) && SlimefunPlugin.getProtectionManager().hasPermission(e.getPlayer(), b.getLocation(), ProtectableAction.BREAK_BLOCK)) {
|
||||
SlimefunPlugin.getProtectionManager().logAction(e.getPlayer(), b, ProtectableAction.BREAK_BLOCK);
|
||||
if (Slimefun.hasUnlocked(e.getPlayer(), this, true)) {
|
||||
e.getBlock().getWorld().createExplosion(e.getBlock().getLocation(), 0.0F);
|
||||
e.getBlock().getWorld().playSound(e.getBlock().getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 0.3F, 1F);
|
||||
|
||||
for (int x = -1; x <= 1; x++) {
|
||||
for (int y = -1; y <= 1; y++) {
|
||||
for (int z = -1; z <= 1; z++) {
|
||||
if (x == 0 && y == 0 && z == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Block b = e.getBlock().getRelative(x, y, z);
|
||||
|
||||
if (b.getType() != Material.AIR && !b.isLiquid() && !MaterialCollections.getAllUnbreakableBlocks().contains(b.getType()) && SlimefunPlugin.getProtectionManager().hasPermission(e.getPlayer(), b.getLocation(), ProtectableAction.BREAK_BLOCK)) {
|
||||
SlimefunPlugin.getProtectionManager().logAction(e.getPlayer(), b, ProtectableAction.BREAK_BLOCK);
|
||||
|
||||
b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType());
|
||||
SlimefunItem sfItem = BlockStorage.check(b);
|
||||
boolean allow = false;
|
||||
|
||||
if (sfItem != null && !(sfItem instanceof HandledBlock)) {
|
||||
if (SlimefunPlugin.getUtilities().blockHandlers.containsKey(sfItem.getID())) {
|
||||
allow = SlimefunPlugin.getUtilities().blockHandlers.get(sfItem.getID()).onBreak(e.getPlayer(), e.getBlock(), sfItem, UnregisterReason.PLAYER_BREAK);
|
||||
b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType());
|
||||
SlimefunItem sfItem = BlockStorage.check(b);
|
||||
boolean allow = false;
|
||||
|
||||
if (sfItem != null && !(sfItem instanceof HandledBlock)) {
|
||||
if (SlimefunPlugin.getUtilities().blockHandlers.containsKey(sfItem.getID())) {
|
||||
allow = SlimefunPlugin.getUtilities().blockHandlers.get(sfItem.getID()).onBreak(e.getPlayer(), e.getBlock(), sfItem, UnregisterReason.PLAYER_BREAK);
|
||||
}
|
||||
if (allow) {
|
||||
drops.add(BlockStorage.retrieve(e.getBlock()));
|
||||
}
|
||||
}
|
||||
if (allow) {
|
||||
drops.add(BlockStorage.retrieve(e.getBlock()));
|
||||
else if (b.getType() == Material.PLAYER_HEAD) {
|
||||
b.breakNaturally();
|
||||
}
|
||||
}
|
||||
else if (b.getType() == Material.PLAYER_HEAD) {
|
||||
b.breakNaturally();
|
||||
}
|
||||
else if (b.getType().name().endsWith("_SHULKER_BOX")) {
|
||||
b.breakNaturally();
|
||||
}
|
||||
else {
|
||||
for (ItemStack drop : b.getDrops(getItem())) {
|
||||
b.getWorld().dropItemNaturally(b.getLocation(), (b.getType().toString().endsWith("_ORE") && b.getType() != Material.IRON_ORE && b.getType() != Material.GOLD_ORE) ? new CustomItem(drop, fortune): drop);
|
||||
else if (b.getType().name().endsWith("_SHULKER_BOX")) {
|
||||
b.breakNaturally();
|
||||
}
|
||||
b.setType(Material.AIR);
|
||||
else {
|
||||
for (ItemStack drop : b.getDrops(getItem())) {
|
||||
b.getWorld().dropItemNaturally(b.getLocation(), (b.getType().toString().endsWith("_ORE") && b.getType() != Material.IRON_ORE && b.getType() != Material.GOLD_ORE) ? new CustomItem(drop, fortune): drop);
|
||||
}
|
||||
b.setType(Material.AIR);
|
||||
}
|
||||
|
||||
damageItem(e.getPlayer(), item);
|
||||
}
|
||||
|
||||
damageItem(e.getPlayer(), item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,31 +35,33 @@ public class ExplosiveShovel extends SimpleSlimefunItem<BlockBreakHandler> imple
|
||||
public BlockBreakHandler getItemHandler() {
|
||||
return (e, item, fortune, drops) -> {
|
||||
if (isItem(item)) {
|
||||
e.getBlock().getWorld().createExplosion(e.getBlock().getLocation(), 0.0F);
|
||||
e.getBlock().getWorld().playSound(e.getBlock().getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 0.3F, 1F);
|
||||
|
||||
for (int x = -1; x <= 1; x++) {
|
||||
for (int y = -1; y <= 1; y++) {
|
||||
for (int z = -1; z <= 1; z++) {
|
||||
if (x == 0 && y == 0 && z == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Block b = e.getBlock().getRelative(x, y, z);
|
||||
|
||||
if (MaterialTools.getBreakableByShovel().contains(b.getType()) && SlimefunPlugin.getProtectionManager().hasPermission(e.getPlayer(), b.getLocation(), ProtectableAction.BREAK_BLOCK)) {
|
||||
SlimefunPlugin.getProtectionManager().logAction(e.getPlayer(), b, ProtectableAction.BREAK_BLOCK);
|
||||
|
||||
b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType());
|
||||
|
||||
for (ItemStack drop : b.getDrops(getItem())) {
|
||||
if (drop != null) {
|
||||
b.getWorld().dropItemNaturally(b.getLocation(), drop);
|
||||
}
|
||||
if (Slimefun.hasUnlocked(e.getPlayer(), this, true)) {
|
||||
e.getBlock().getWorld().createExplosion(e.getBlock().getLocation(), 0.0F);
|
||||
e.getBlock().getWorld().playSound(e.getBlock().getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 0.3F, 1F);
|
||||
|
||||
for (int x = -1; x <= 1; x++) {
|
||||
for (int y = -1; y <= 1; y++) {
|
||||
for (int z = -1; z <= 1; z++) {
|
||||
if (x == 0 && y == 0 && z == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
b.setType(Material.AIR);
|
||||
damageItem(e.getPlayer(), item);
|
||||
Block b = e.getBlock().getRelative(x, y, z);
|
||||
|
||||
if (MaterialTools.getBreakableByShovel().contains(b.getType()) && SlimefunPlugin.getProtectionManager().hasPermission(e.getPlayer(), b.getLocation(), ProtectableAction.BREAK_BLOCK)) {
|
||||
SlimefunPlugin.getProtectionManager().logAction(e.getPlayer(), b, ProtectableAction.BREAK_BLOCK);
|
||||
|
||||
b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType());
|
||||
|
||||
for (ItemStack drop : b.getDrops(getItem())) {
|
||||
if (drop != null) {
|
||||
b.getWorld().dropItemNaturally(b.getLocation(), drop);
|
||||
}
|
||||
}
|
||||
|
||||
b.setType(Material.AIR);
|
||||
damageItem(e.getPlayer(), item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,14 +22,10 @@ public class FortuneCookie extends SimpleSlimefunItem<ItemConsumptionHandler> {
|
||||
@Override
|
||||
public ItemConsumptionHandler getItemHandler() {
|
||||
return (e, p, item) -> {
|
||||
if (isItem(item)) {
|
||||
List<String> messages = SlimefunPlugin.getLocal().getMessages(p, "messages.fortune-cookie");
|
||||
String message = messages.get(ThreadLocalRandom.current().nextInt(messages.size()));
|
||||
|
||||
p.sendMessage(ChatColors.color(message));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
List<String> messages = SlimefunPlugin.getLocal().getMessages(p, "messages.fortune-cookie");
|
||||
String message = messages.get(ThreadLocalRandom.current().nextInt(messages.size()));
|
||||
|
||||
p.sendMessage(ChatColors.color(message));
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Material;
|
||||
@ -16,11 +17,11 @@ import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.interfaces.RecipeDisplayItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemInteractionHandler;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemUseHandler;
|
||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class GoldPan extends SimpleSlimefunItem<ItemInteractionHandler> implements RecipeDisplayItem {
|
||||
public class GoldPan extends SimpleSlimefunItem<ItemUseHandler> implements RecipeDisplayItem {
|
||||
|
||||
private final List<ItemStack> recipes;
|
||||
private final RandomizedSet<ItemStack> randomizer = new RandomizedSet<>();
|
||||
@ -55,14 +56,16 @@ public class GoldPan extends SimpleSlimefunItem<ItemInteractionHandler> implemen
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemInteractionHandler getItemHandler() {
|
||||
return (e, p, item) -> {
|
||||
if (isItem(item)) {
|
||||
Block b = e.getClickedBlock();
|
||||
public ItemUseHandler getItemHandler() {
|
||||
return e -> {
|
||||
Optional<Block> block = e.getClickedBlock();
|
||||
|
||||
if (block.isPresent()) {
|
||||
Block b = block.get();
|
||||
|
||||
if (b != null && b.getType() == Material.GRAVEL && SlimefunPlugin.getProtectionManager().hasPermission(p, b.getLocation(), ProtectableAction.BREAK_BLOCK)) {
|
||||
if (b.getType() == Material.GRAVEL && SlimefunPlugin.getProtectionManager().hasPermission(e.getPlayer(), b.getLocation(), ProtectableAction.BREAK_BLOCK)) {
|
||||
ItemStack output = randomizer.getRandom();
|
||||
|
||||
|
||||
b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType());
|
||||
b.setType(Material.AIR);
|
||||
|
||||
@ -70,11 +73,9 @@ public class GoldPan extends SimpleSlimefunItem<ItemInteractionHandler> implemen
|
||||
b.getWorld().dropItemNaturally(b.getLocation(), output.clone());
|
||||
}
|
||||
}
|
||||
|
||||
e.setCancelled(true);
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
|
||||
e.cancel();
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Bat;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
@ -16,12 +17,12 @@ import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemInteractionHandler;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemUseHandler;
|
||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
import me.mrCookieSlime.Slimefun.utils.Utilities;
|
||||
|
||||
public class GrapplingHook extends SimpleSlimefunItem<ItemInteractionHandler> {
|
||||
public class GrapplingHook extends SimpleSlimefunItem<ItemUseHandler> {
|
||||
|
||||
private long despawnTicks;
|
||||
|
||||
@ -30,60 +31,60 @@ public class GrapplingHook extends SimpleSlimefunItem<ItemInteractionHandler> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemInteractionHandler getItemHandler() {
|
||||
public ItemUseHandler getItemHandler() {
|
||||
Utilities utilities = SlimefunPlugin.getUtilities();
|
||||
|
||||
return (e, p, item) -> {
|
||||
if (isItem(item)) {
|
||||
UUID uuid = p.getUniqueId();
|
||||
return e -> {
|
||||
Player p = e.getPlayer();
|
||||
UUID uuid = p.getUniqueId();
|
||||
|
||||
if (!e.getClickedBlock().isPresent() && !utilities.jumpState.containsKey(uuid)) {
|
||||
e.cancel();
|
||||
|
||||
if (e.getClickedBlock() == null && !utilities.jumpState.containsKey(uuid)) {
|
||||
e.setCancelled(true);
|
||||
|
||||
if (p.getInventory().getItemInOffHand().getType() == Material.BOW) {
|
||||
// Cancel, to fix dupe #740
|
||||
return false;
|
||||
}
|
||||
utilities.jumpState.put(uuid, p.getInventory().getItemInMainHand().getType() != Material.SHEARS);
|
||||
|
||||
if (item.getType() == Material.LEAD) {
|
||||
item.setAmount(item.getAmount() - 1);
|
||||
}
|
||||
|
||||
Vector direction = p.getEyeLocation().getDirection().multiply(2.0);
|
||||
Arrow arrow = p.getWorld().spawn(p.getEyeLocation().add(direction.getX(), direction.getY(), direction.getZ()), Arrow.class);
|
||||
arrow.setShooter(p);
|
||||
arrow.setVelocity(direction);
|
||||
|
||||
Bat b = (Bat) p.getWorld().spawnEntity(p.getLocation(), EntityType.BAT);
|
||||
b.setCanPickupItems(false);
|
||||
b.setAI(false);
|
||||
b.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 100000, 100000));
|
||||
b.setLeashHolder(arrow);
|
||||
|
||||
utilities.damage.add(uuid);
|
||||
utilities.remove.put(uuid, new Entity[]{b, arrow});
|
||||
|
||||
// To fix issue #253
|
||||
Slimefun.runSync(() -> {
|
||||
if (utilities.jumpState.containsKey(uuid)) {
|
||||
utilities.arrows.remove(uuid);
|
||||
|
||||
for (Entity n : utilities.remove.get(uuid)) {
|
||||
if (n.isValid()) n.remove();
|
||||
}
|
||||
|
||||
Slimefun.runSync(() -> {
|
||||
utilities.damage.remove(uuid);
|
||||
utilities.jumpState.remove(uuid);
|
||||
utilities.remove.remove(uuid);
|
||||
}, 20L);
|
||||
}
|
||||
}, despawnTicks);
|
||||
ItemStack item = e.getItem();
|
||||
|
||||
if (p.getInventory().getItemInOffHand().getType() == Material.BOW) {
|
||||
// Cancel, to fix dupe #740
|
||||
return;
|
||||
}
|
||||
return true;
|
||||
|
||||
utilities.jumpState.put(uuid, p.getInventory().getItemInMainHand().getType() != Material.SHEARS);
|
||||
|
||||
if (item.getType() == Material.LEAD) {
|
||||
item.setAmount(item.getAmount() - 1);
|
||||
}
|
||||
|
||||
Vector direction = p.getEyeLocation().getDirection().multiply(2.0);
|
||||
Arrow arrow = p.getWorld().spawn(p.getEyeLocation().add(direction.getX(), direction.getY(), direction.getZ()), Arrow.class);
|
||||
arrow.setShooter(p);
|
||||
arrow.setVelocity(direction);
|
||||
|
||||
Bat b = (Bat) p.getWorld().spawnEntity(p.getLocation(), EntityType.BAT);
|
||||
b.setCanPickupItems(false);
|
||||
b.setAI(false);
|
||||
b.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 100000, 100000));
|
||||
b.setLeashHolder(arrow);
|
||||
|
||||
utilities.damage.add(uuid);
|
||||
utilities.remove.put(uuid, new Entity[]{b, arrow});
|
||||
|
||||
// To fix issue #253
|
||||
Slimefun.runSync(() -> {
|
||||
if (utilities.jumpState.containsKey(uuid)) {
|
||||
utilities.arrows.remove(uuid);
|
||||
|
||||
for (Entity n : utilities.remove.get(uuid)) {
|
||||
if (n.isValid()) n.remove();
|
||||
}
|
||||
|
||||
Slimefun.runSync(() -> {
|
||||
utilities.damage.remove(uuid);
|
||||
utilities.jumpState.remove(uuid);
|
||||
utilities.remove.remove(uuid);
|
||||
}, 20L);
|
||||
}
|
||||
}, despawnTicks);
|
||||
}
|
||||
else return false;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockBreakHandler;
|
||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class HerculesPickaxe extends SimpleSlimefunItem<BlockBreakHandler> {
|
||||
@ -26,6 +27,8 @@ public class HerculesPickaxe extends SimpleSlimefunItem<BlockBreakHandler> {
|
||||
public BlockBreakHandler getItemHandler() {
|
||||
return (e, item, fortune, drops) -> {
|
||||
if (isItem(item) && e.getBlock().getType().toString().endsWith("_ORE")) {
|
||||
if (!Slimefun.hasUnlocked(e.getPlayer(), this, true)) return true;
|
||||
|
||||
if (e.getBlock().getType() == Material.IRON_ORE) {
|
||||
drops.add(new CustomItem(SlimefunItems.IRON_DUST, 2));
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
@ -11,22 +13,24 @@ import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemInteractionHandler;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemUseHandler;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class InfernalBonemeal extends SimpleSlimefunItem<ItemInteractionHandler> {
|
||||
public class InfernalBonemeal extends SimpleSlimefunItem<ItemUseHandler> {
|
||||
|
||||
public InfernalBonemeal(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) {
|
||||
super(category, item, recipeType, recipe, recipeOutput);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemInteractionHandler getItemHandler() {
|
||||
return (e, p, item) -> {
|
||||
if (isItem(item)) {
|
||||
Block b = e.getClickedBlock();
|
||||
public ItemUseHandler getItemHandler() {
|
||||
return e -> {
|
||||
Optional<Block> block = e.getClickedBlock();
|
||||
|
||||
if (block.isPresent()) {
|
||||
Block b = block.get();
|
||||
|
||||
if (b != null && b.getType() == Material.NETHER_WART) {
|
||||
if (b.getType() == Material.NETHER_WART) {
|
||||
Ageable ageable = (Ageable) b.getBlockData();
|
||||
|
||||
if (ageable.getAge() < ageable.getMaximumAge()) {
|
||||
@ -34,14 +38,12 @@ public class InfernalBonemeal extends SimpleSlimefunItem<ItemInteractionHandler>
|
||||
b.setBlockData(ageable);
|
||||
b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, Material.REDSTONE_BLOCK);
|
||||
|
||||
if (p.getGameMode() != GameMode.CREATIVE) {
|
||||
ItemUtils.consumeItem(item, false);
|
||||
if (e.getPlayer().getGameMode() != GameMode.CREATIVE) {
|
||||
ItemUtils.consumeItem(e.getItem(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -3,37 +3,36 @@ package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Container;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemInteractionHandler;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemUseHandler;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class KnowledgeFlask extends SimpleSlimefunItem<ItemInteractionHandler> {
|
||||
public class KnowledgeFlask extends SimpleSlimefunItem<ItemUseHandler> {
|
||||
|
||||
public KnowledgeFlask(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) {
|
||||
super(category, item, recipeType, recipe, recipeOutput);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemInteractionHandler getItemHandler() {
|
||||
return (e, p, item) -> {
|
||||
if (isItem(item) && p.getLevel() >= 1) {
|
||||
if (e.getClickedBlock() == null || !(e.getClickedBlock().getState() instanceof Container)) {
|
||||
p.setLevel(p.getLevel() - 1);
|
||||
e.setCancelled(true);
|
||||
p.getInventory().addItem(new CustomItem(Material.EXPERIENCE_BOTTLE, "&aFlask of Knowledge"));
|
||||
public ItemUseHandler getItemHandler() {
|
||||
return e -> {
|
||||
Player p = e.getPlayer();
|
||||
if (p.getLevel() >= 1 && (!e.getClickedBlock().isPresent() || !(e.getClickedBlock().get().getState() instanceof Container))) {
|
||||
p.setLevel(p.getLevel() - 1);
|
||||
p.getInventory().addItem(new CustomItem(Material.EXPERIENCE_BOTTLE, "&aFlask of Knowledge"));
|
||||
|
||||
p.playSound(p.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1F, 0.5F);
|
||||
p.playSound(p.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1F, 0.5F);
|
||||
|
||||
item.setAmount(item.getAmount() - 1);
|
||||
}
|
||||
return true;
|
||||
ItemStack item = e.getItem();
|
||||
item.setAmount(item.getAmount() - 1);
|
||||
e.cancel();
|
||||
}
|
||||
else return false;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -7,54 +7,59 @@ import java.util.UUID;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Research;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemInteractionHandler;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemUseHandler;
|
||||
import me.mrCookieSlime.Slimefun.api.PlayerProfile;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class KnowledgeTome extends SimpleSlimefunItem<ItemInteractionHandler> {
|
||||
public class KnowledgeTome extends SimpleSlimefunItem<ItemUseHandler> {
|
||||
|
||||
public KnowledgeTome(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, item, recipeType, recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemInteractionHandler getItemHandler() {
|
||||
return (e, p, item) -> {
|
||||
if (isItem(item)) {
|
||||
ItemMeta im = item.getItemMeta();
|
||||
List<String> lore = im.getLore();
|
||||
public ItemUseHandler getItemHandler() {
|
||||
return e -> {
|
||||
Player p = e.getPlayer();
|
||||
ItemStack item = e.getItem();
|
||||
|
||||
ItemMeta im = item.getItemMeta();
|
||||
List<String> lore = im.getLore();
|
||||
|
||||
if (lore.get(1).isEmpty()) {
|
||||
lore.set(0, ChatColor.translateAlternateColorCodes('&', "&7Owner: &b" + p.getName()));
|
||||
lore.set(1, ChatColor.BLACK + "" + p.getUniqueId());
|
||||
im.setLore(lore);
|
||||
item.setItemMeta(im);
|
||||
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1F, 1F);
|
||||
}
|
||||
else {
|
||||
UUID uuid = UUID.fromString(ChatColor.stripColor(item.getItemMeta().getLore().get(1)));
|
||||
|
||||
if (lore.get(1).isEmpty()) {
|
||||
lore.set(0, ChatColor.translateAlternateColorCodes('&', "&7Owner: &b" + p.getName()));
|
||||
lore.set(1, ChatColor.BLACK + "" + p.getUniqueId());
|
||||
im.setLore(lore);
|
||||
item.setItemMeta(im);
|
||||
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1F, 1F);
|
||||
}
|
||||
else {
|
||||
UUID uuid = UUID.fromString(ChatColor.stripColor(item.getItemMeta().getLore().get(1)));
|
||||
|
||||
if (p.getUniqueId().equals(uuid))
|
||||
return true;
|
||||
|
||||
PlayerProfile.get(p, profile -> PlayerProfile.fromUUID(uuid, owner -> {
|
||||
Set<Research> researches = owner.getResearches();
|
||||
researches.forEach(research -> research.unlock(p, true));
|
||||
}));
|
||||
|
||||
if (p.getGameMode() != GameMode.CREATIVE)
|
||||
item.setAmount(item.getAmount() - 1);
|
||||
if (p.getUniqueId().equals(uuid)) {
|
||||
SlimefunPlugin.getLocal().sendMessage(p, "messages.no-tome-yourself");
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerProfile.get(p, profile -> PlayerProfile.fromUUID(uuid, owner -> {
|
||||
Set<Research> researches = owner.getResearches();
|
||||
researches.forEach(research -> research.unlock(p, true));
|
||||
}));
|
||||
|
||||
if (p.getGameMode() != GameMode.CREATIVE) {
|
||||
ItemUtils.consumeItem(item, false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,7 @@ import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.interfaces.NotPlaceable;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockBreakHandler;
|
||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class LumberAxe extends SimpleSlimefunItem<BlockBreakHandler> implements NotPlaceable {
|
||||
@ -33,6 +34,8 @@ public class LumberAxe extends SimpleSlimefunItem<BlockBreakHandler> implements
|
||||
public BlockBreakHandler getItemHandler() {
|
||||
return (e, item, fortune, drops) -> {
|
||||
if (isItem(item)) {
|
||||
if (!Slimefun.hasUnlocked(e.getPlayer(), this, true)) return true;
|
||||
|
||||
if (MaterialCollections.getAllLogs().contains(e.getBlock().getType())) {
|
||||
List<Block> logs = Vein.find(e.getBlock(), 100, b -> MaterialCollections.getAllLogs().contains(b.getType()));
|
||||
|
||||
|
@ -2,40 +2,39 @@ package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items;
|
||||
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.EnderPearl;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemInteractionHandler;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemUseHandler;
|
||||
import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class MagicEyeOfEnder extends SimpleSlimefunItem<ItemInteractionHandler> {
|
||||
public class MagicEyeOfEnder extends SimpleSlimefunItem<ItemUseHandler> {
|
||||
|
||||
public MagicEyeOfEnder(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, item, recipeType, recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemInteractionHandler getItemHandler() {
|
||||
return (e, p, item) -> {
|
||||
if (isItem(item)) {
|
||||
e.setCancelled(true);
|
||||
|
||||
if (
|
||||
SlimefunManager.isItemSimilar(p.getInventory().getHelmet(), SlimefunItems.ENDER_HELMET, true) &&
|
||||
SlimefunManager.isItemSimilar(p.getInventory().getChestplate(), SlimefunItems.ENDER_CHESTPLATE, true) &&
|
||||
SlimefunManager.isItemSimilar(p.getInventory().getLeggings(), SlimefunItems.ENDER_LEGGINGS, true) &&
|
||||
SlimefunManager.isItemSimilar(p.getInventory().getBoots(), SlimefunItems.ENDER_BOOTS, true)
|
||||
) {
|
||||
p.launchProjectile(EnderPearl.class);
|
||||
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 1, 1);
|
||||
}
|
||||
return true;
|
||||
public ItemUseHandler getItemHandler() {
|
||||
return e -> {
|
||||
e.cancel();
|
||||
|
||||
Player p = e.getPlayer();
|
||||
|
||||
if (
|
||||
SlimefunManager.isItemSimilar(p.getInventory().getHelmet(), SlimefunItems.ENDER_HELMET, true) &&
|
||||
SlimefunManager.isItemSimilar(p.getInventory().getChestplate(), SlimefunItems.ENDER_CHESTPLATE, true) &&
|
||||
SlimefunManager.isItemSimilar(p.getInventory().getLeggings(), SlimefunItems.ENDER_LEGGINGS, true) &&
|
||||
SlimefunManager.isItemSimilar(p.getInventory().getBoots(), SlimefunItems.ENDER_BOOTS, true)
|
||||
) {
|
||||
p.launchProjectile(EnderPearl.class);
|
||||
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 1, 1);
|
||||
}
|
||||
else return false;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
@ -11,38 +12,34 @@ import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemInteractionHandler;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemUseHandler;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class MagicSugar extends SimpleSlimefunItem<ItemInteractionHandler> {
|
||||
public class MagicSugar extends SimpleSlimefunItem<ItemUseHandler> {
|
||||
|
||||
public MagicSugar(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, item, recipeType, recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemInteractionHandler getItemHandler() {
|
||||
return (e, p, item) -> {
|
||||
if (isItem(item)) {
|
||||
//Check if it is being placed into an ancient altar.
|
||||
if (e.getClickedBlock() != null) {
|
||||
Material block = e.getClickedBlock().getType();
|
||||
|
||||
if (block == Material.DISPENSER || block == Material.ENCHANTING_TABLE) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (p.getGameMode() != GameMode.CREATIVE) {
|
||||
ItemUtils.consumeItem(item, false);
|
||||
}
|
||||
public ItemUseHandler getItemHandler() {
|
||||
return e -> {
|
||||
//Check if it is being placed into an ancient altar.
|
||||
if (e.getClickedBlock().isPresent()) {
|
||||
Material block = e.getClickedBlock().get().getType();
|
||||
|
||||
if (block == Material.DISPENSER || block == Material.ENCHANTING_TABLE) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_GENERIC_EAT, 1, 1);
|
||||
p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 600, 3));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
Player p = e.getPlayer();
|
||||
if (p.getGameMode() != GameMode.CREATIVE) {
|
||||
ItemUtils.consumeItem(e.getItem(), false);
|
||||
}
|
||||
|
||||
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_GENERIC_EAT, 1, 1);
|
||||
p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 600, 3));
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -24,13 +24,7 @@ public class MeatJerky extends SimpleSlimefunItem<ItemConsumptionHandler> {
|
||||
|
||||
@Override
|
||||
public ItemConsumptionHandler getItemHandler() {
|
||||
return (e, p, item) -> {
|
||||
if (isItem(item)) {
|
||||
p.setSaturation(saturation);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
return (e, p, item) -> p.setSaturation(saturation);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,33 @@
|
||||
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemConsumptionHandler;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class Medicine extends SimpleSlimefunItem<ItemConsumptionHandler> {
|
||||
|
||||
public Medicine(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, item, recipeType, recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemConsumptionHandler getItemHandler() {
|
||||
return (e, p, item) -> {
|
||||
if (p.hasPotionEffect(PotionEffectType.POISON)) p.removePotionEffect(PotionEffectType.POISON);
|
||||
if (p.hasPotionEffect(PotionEffectType.WITHER)) p.removePotionEffect(PotionEffectType.WITHER);
|
||||
if (p.hasPotionEffect(PotionEffectType.SLOW)) p.removePotionEffect(PotionEffectType.SLOW);
|
||||
if (p.hasPotionEffect(PotionEffectType.SLOW_DIGGING)) p.removePotionEffect(PotionEffectType.SLOW_DIGGING);
|
||||
if (p.hasPotionEffect(PotionEffectType.WEAKNESS)) p.removePotionEffect(PotionEffectType.WEAKNESS);
|
||||
if (p.hasPotionEffect(PotionEffectType.CONFUSION)) p.removePotionEffect(PotionEffectType.CONFUSION);
|
||||
if (p.hasPotionEffect(PotionEffectType.BLINDNESS)) p.removePotionEffect(PotionEffectType.BLINDNESS);
|
||||
|
||||
p.setFireTicks(0);
|
||||
};
|
||||
}
|
||||
|
||||
}
|
@ -20,19 +20,13 @@ public class MonsterJerky extends SimpleSlimefunItem<ItemConsumptionHandler> {
|
||||
@Override
|
||||
public ItemConsumptionHandler getItemHandler() {
|
||||
return (e, p, item) -> {
|
||||
if (isItem(item)) {
|
||||
Slimefun.runSync(() -> {
|
||||
if (p.hasPotionEffect(PotionEffectType.HUNGER)) {
|
||||
p.removePotionEffect(PotionEffectType.HUNGER);
|
||||
}
|
||||
|
||||
p.addPotionEffect(new PotionEffect(PotionEffectType.SATURATION, 5, 0));
|
||||
}, 1L);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
Slimefun.runSync(() -> {
|
||||
if (p.hasPotionEffect(PotionEffectType.HUNGER)) {
|
||||
p.removePotionEffect(PotionEffectType.HUNGER);
|
||||
}
|
||||
|
||||
p.addPotionEffect(new PotionEffect(PotionEffectType.SATURATION, 5, 0));
|
||||
}, 1L);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,9 @@
|
||||
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
||||
@ -8,32 +11,33 @@ import io.github.thebusybiscuit.cscorelib2.math.DoubleHandler;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemInteractionHandler;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemUseHandler;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
import me.mrCookieSlime.Slimefun.api.energy.ChargableBlock;
|
||||
|
||||
public class Multimeter extends SimpleSlimefunItem<ItemInteractionHandler> {
|
||||
public class Multimeter extends SimpleSlimefunItem<ItemUseHandler> {
|
||||
|
||||
public Multimeter(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, item, recipeType, recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemInteractionHandler getItemHandler() {
|
||||
return (e, p, item) -> {
|
||||
if (isItem(item)) {
|
||||
Block b = e.getClickedBlock();
|
||||
|
||||
if (b != null && ChargableBlock.isChargable(b)) {
|
||||
e.setCancelled(true);
|
||||
p.sendMessage("");
|
||||
p.sendMessage(ChatColors.color("&bStored Energy: &3" + DoubleHandler.getFancyDouble(ChargableBlock.getCharge(b)) + " J"));
|
||||
p.sendMessage(ChatColors.color("&bCapacity: &3" + DoubleHandler.getFancyDouble(ChargableBlock.getMaxCharge(b)) + " J"));
|
||||
p.sendMessage("");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
public ItemUseHandler getItemHandler() {
|
||||
return e -> {
|
||||
Optional<Block> block = e.getClickedBlock();
|
||||
|
||||
if (block.isPresent()) {
|
||||
Block b = block.get();
|
||||
if (ChargableBlock.isChargable(b)) {
|
||||
e.cancel();
|
||||
|
||||
Player p = e.getPlayer();
|
||||
p.sendMessage("");
|
||||
p.sendMessage(ChatColors.color("&bStored Energy: &3" + DoubleHandler.getFancyDouble(ChargableBlock.getCharge(b)) + " J"));
|
||||
p.sendMessage(ChatColors.color("&bCapacity: &3" + DoubleHandler.getFancyDouble(ChargableBlock.getMaxCharge(b)) + " J"));
|
||||
p.sendMessage("");
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Material;
|
||||
@ -15,11 +16,11 @@ import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.interfaces.RecipeDisplayItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemInteractionHandler;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemUseHandler;
|
||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class NetherGoldPan extends SimpleSlimefunItem<ItemInteractionHandler> implements RecipeDisplayItem {
|
||||
public class NetherGoldPan extends SimpleSlimefunItem<ItemUseHandler> implements RecipeDisplayItem {
|
||||
|
||||
private final List<ItemStack> recipes;
|
||||
private final RandomizedSet<ItemStack> randomizer = new RandomizedSet<>();
|
||||
@ -61,12 +62,14 @@ public class NetherGoldPan extends SimpleSlimefunItem<ItemInteractionHandler> im
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemInteractionHandler getItemHandler() {
|
||||
return (e, p, item) -> {
|
||||
if (isItem(item)) {
|
||||
Block b = e.getClickedBlock();
|
||||
public ItemUseHandler getItemHandler() {
|
||||
return e -> {
|
||||
Optional<Block> block = e.getClickedBlock();
|
||||
|
||||
if (block.isPresent()) {
|
||||
Block b = block.get();
|
||||
|
||||
if (b != null && b.getType() == Material.SOUL_SAND && SlimefunPlugin.getProtectionManager().hasPermission(p, b.getLocation(), ProtectableAction.BREAK_BLOCK)) {
|
||||
if (b.getType() == Material.SOUL_SAND && SlimefunPlugin.getProtectionManager().hasPermission(e.getPlayer(), b.getLocation(), ProtectableAction.BREAK_BLOCK)) {
|
||||
ItemStack output = randomizer.getRandom();
|
||||
|
||||
b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType());
|
||||
@ -76,10 +79,8 @@ public class NetherGoldPan extends SimpleSlimefunItem<ItemInteractionHandler> im
|
||||
b.getWorld().dropItemNaturally(b.getLocation(), output.clone());
|
||||
}
|
||||
}
|
||||
e.setCancelled(true);
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
e.cancel();
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections;
|
||||
@ -10,53 +11,50 @@ import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.interfaces.DamageableItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemInteractionHandler;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemUseHandler;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class PickaxeOfTheSeeker extends SimpleSlimefunItem<ItemInteractionHandler> implements DamageableItem {
|
||||
public class PickaxeOfTheSeeker extends SimpleSlimefunItem<ItemUseHandler> implements DamageableItem {
|
||||
|
||||
public PickaxeOfTheSeeker(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, item, recipeType, recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemInteractionHandler getItemHandler() {
|
||||
return (e, p, item) -> {
|
||||
if (isItem(item)) {
|
||||
Block closest = null;
|
||||
public ItemUseHandler getItemHandler() {
|
||||
return e -> {
|
||||
Player p = e.getPlayer();
|
||||
Block closest = null;
|
||||
|
||||
for (int x = -4; x <= 4; x++) {
|
||||
for (int y = -4; y <= 4; y++) {
|
||||
for (int z = -4; z <= 4; z++) {
|
||||
if (MaterialCollections.getAllOres().contains(p.getLocation().getBlock().getRelative(x, y, z).getType()) && (closest == null || p.getLocation().distanceSquared(closest.getLocation()) > p.getLocation().distanceSquared(p.getLocation().getBlock().getRelative(x, y, z).getLocation()))) {
|
||||
closest = p.getLocation().getBlock().getRelative(x, y, z);
|
||||
}
|
||||
for (int x = -4; x <= 4; x++) {
|
||||
for (int y = -4; y <= 4; y++) {
|
||||
for (int z = -4; z <= 4; z++) {
|
||||
if (MaterialCollections.getAllOres().contains(p.getLocation().getBlock().getRelative(x, y, z).getType()) && (closest == null || p.getLocation().distanceSquared(closest.getLocation()) > p.getLocation().distanceSquared(p.getLocation().getBlock().getRelative(x, y, z).getLocation()))) {
|
||||
closest = p.getLocation().getBlock().getRelative(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (closest == null) {
|
||||
SlimefunPlugin.getLocal().sendMessage(p, "miner.no-ores", true);
|
||||
}
|
||||
else {
|
||||
double l = closest.getX() + 0.5 - p.getLocation().getX();
|
||||
double w = closest.getZ() + 0.5 - p.getLocation().getZ();
|
||||
float yaw;
|
||||
float pitch;
|
||||
double c = Math.sqrt(l * l + w * w);
|
||||
double alpha1 = -Math.asin(l / c) / Math.PI * 180;
|
||||
double alpha2 = Math.acos(w / c) / Math.PI * 180;
|
||||
if (alpha2 > 90) yaw = (float) (180 - alpha1);
|
||||
else yaw = (float) alpha1;
|
||||
pitch = (float) ((-Math.atan((closest.getY() - 0.5 - p.getLocation().getY()) / Math.sqrt(l * l + w * w))) * 180F / Math.PI);
|
||||
|
||||
p.teleport(new Location(p.getWorld(), p.getLocation().getX(), p.getLocation().getY(), p.getLocation().getZ(), yaw, pitch));
|
||||
}
|
||||
|
||||
damageItem(p, item);
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
|
||||
if (closest == null) {
|
||||
SlimefunPlugin.getLocal().sendMessage(p, "miner.no-ores");
|
||||
}
|
||||
else {
|
||||
double l = closest.getX() + 0.5 - p.getLocation().getX();
|
||||
double w = closest.getZ() + 0.5 - p.getLocation().getZ();
|
||||
float yaw;
|
||||
float pitch;
|
||||
double c = Math.sqrt(l * l + w * w);
|
||||
double alpha1 = -Math.asin(l / c) / Math.PI * 180;
|
||||
double alpha2 = Math.acos(w / c) / Math.PI * 180;
|
||||
if (alpha2 > 90) yaw = (float) (180 - alpha1);
|
||||
else yaw = (float) alpha1;
|
||||
pitch = (float) ((-Math.atan((closest.getY() - 0.5 - p.getLocation().getY()) / Math.sqrt(l * l + w * w))) * 180F / Math.PI);
|
||||
|
||||
p.teleport(new Location(p.getWorld(), p.getLocation().getX(), p.getLocation().getY(), p.getLocation().getZ(), yaw, pitch));
|
||||
}
|
||||
|
||||
damageItem(p, e.getItem());
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1,29 +1,27 @@
|
||||
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items;
|
||||
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemInteractionHandler;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemUseHandler;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class PortableCrafter extends SimpleSlimefunItem<ItemInteractionHandler> {
|
||||
public class PortableCrafter extends SimpleSlimefunItem<ItemUseHandler> {
|
||||
|
||||
public PortableCrafter(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, item, recipeType, recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemInteractionHandler getItemHandler() {
|
||||
return (e, p, item) -> {
|
||||
if (isItem(item)) {
|
||||
p.openWorkbench(p.getLocation(), true);
|
||||
p.getWorld().playSound(p.getLocation(), Sound.BLOCK_WOODEN_BUTTON_CLICK_ON, 1, 1);
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
public ItemUseHandler getItemHandler() {
|
||||
return e -> {
|
||||
Player p = e.getPlayer();
|
||||
p.openWorkbench(p.getLocation(), true);
|
||||
p.getWorld().playSound(p.getLocation(), Sound.BLOCK_WOODEN_BUTTON_CLICK_ON, 1, 1);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -3,30 +3,29 @@ package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemInteractionHandler;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemUseHandler;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class PortableDustbin extends SimpleSlimefunItem<ItemInteractionHandler> {
|
||||
public class PortableDustbin extends SimpleSlimefunItem<ItemUseHandler> {
|
||||
|
||||
public PortableDustbin(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, item, recipeType, recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemInteractionHandler getItemHandler() {
|
||||
return (e, p, item) -> {
|
||||
if (isItem(item)) {
|
||||
e.setCancelled(true);
|
||||
p.openInventory(Bukkit.createInventory(null, 9 * 3, ChatColor.DARK_RED + "Delete Items"));
|
||||
p.playSound(p.getLocation(), Sound.BLOCK_ANVIL_LAND, 1, 1);
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
public ItemUseHandler getItemHandler() {
|
||||
return e -> {
|
||||
e.cancel();
|
||||
|
||||
Player p = e.getPlayer();
|
||||
p.openInventory(Bukkit.createInventory(null, 9 * 3, ChatColor.DARK_RED + "Delete Items"));
|
||||
p.playSound(p.getLocation(), Sound.BLOCK_ANVIL_LAND, 1, 1);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,29 +1,27 @@
|
||||
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.GEO.GEOScanner;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemInteractionHandler;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemUseHandler;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class PortableGEOScanner extends SimpleSlimefunItem<ItemInteractionHandler> {
|
||||
public class PortableGEOScanner extends SimpleSlimefunItem<ItemUseHandler> {
|
||||
|
||||
public PortableGEOScanner(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, item, recipeType, recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemInteractionHandler getItemHandler() {
|
||||
return (e, p, item) -> {
|
||||
if (isItem(item)) {
|
||||
e.setCancelled(true);
|
||||
GEOScanner.scanChunk(p, p.getLocation().getChunk());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
public ItemUseHandler getItemHandler() {
|
||||
return e -> {
|
||||
e.cancel();
|
||||
Player p = e.getPlayer();
|
||||
GEOScanner.scanChunk(p, p.getLocation().getChunk());
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,41 @@
|
||||
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemUseHandler;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class Rag extends SimpleSlimefunItem<ItemUseHandler> {
|
||||
|
||||
public Rag(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, item, recipeType, recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemUseHandler getItemHandler() {
|
||||
return e -> {
|
||||
Player p = e.getPlayer();
|
||||
|
||||
if (p.getGameMode() != GameMode.CREATIVE) {
|
||||
ItemUtils.consumeItem(e.getItem(), false);
|
||||
}
|
||||
|
||||
p.getWorld().playEffect(p.getLocation(), Effect.STEP_SOUND, Material.WHITE_WOOL);
|
||||
p.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 0));
|
||||
p.setFireTicks(0);
|
||||
|
||||
e.cancel();
|
||||
};
|
||||
}
|
||||
|
||||
}
|
@ -11,6 +11,7 @@ import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -22,64 +23,62 @@ import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.interfaces.DamageableItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.interfaces.NotPlaceable;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemInteractionHandler;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemUseHandler;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class SeismicAxe extends SimpleSlimefunItem<ItemInteractionHandler> implements NotPlaceable, DamageableItem {
|
||||
public class SeismicAxe extends SimpleSlimefunItem<ItemUseHandler> implements NotPlaceable, DamageableItem {
|
||||
|
||||
public SeismicAxe(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, item, recipeType, recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemInteractionHandler getItemHandler() {
|
||||
return (e, p, item) -> {
|
||||
if (isItem(item)) {
|
||||
List<Block> blocks = p.getLineOfSight(null, 10);
|
||||
for (int i = 0; i < blocks.size(); i++) {
|
||||
Block b = blocks.get(i);
|
||||
Location ground = b.getLocation();
|
||||
|
||||
if (b.getType() == null || b.getType() == Material.AIR) {
|
||||
for (int y = ground.getBlockY(); y > 0; y--) {
|
||||
if (b.getWorld().getBlockAt(b.getX(), y, b.getZ()) != null && b.getWorld().getBlockAt(b.getX(), y, b.getZ()).getType() != null && b.getWorld().getBlockAt(b.getX(), y, b.getZ()).getType() != Material.AIR) {
|
||||
ground = new Location(b.getWorld(), b.getX(), y, b.getZ());
|
||||
break;
|
||||
}
|
||||
public ItemUseHandler getItemHandler() {
|
||||
return e -> {
|
||||
Player p = e.getPlayer();
|
||||
List<Block> blocks = p.getLineOfSight(null, 10);
|
||||
|
||||
for (int i = 0; i < blocks.size(); i++) {
|
||||
Block b = blocks.get(i);
|
||||
Location ground = b.getLocation();
|
||||
|
||||
if (b.getType() == null || b.getType() == Material.AIR) {
|
||||
for (int y = ground.getBlockY(); y > 0; y--) {
|
||||
if (b.getWorld().getBlockAt(b.getX(), y, b.getZ()) != null && b.getWorld().getBlockAt(b.getX(), y, b.getZ()).getType() != null && b.getWorld().getBlockAt(b.getX(), y, b.getZ()).getType() != Material.AIR) {
|
||||
ground = new Location(b.getWorld(), b.getX(), y, b.getZ());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
b.getWorld().playEffect(ground, Effect.STEP_SOUND, ground.getBlock().getType());
|
||||
|
||||
if (ground.getBlock().getRelative(BlockFace.UP).getType() == null || ground.getBlock().getRelative(BlockFace.UP).getType() == Material.AIR) {
|
||||
Location loc = ground.getBlock().getRelative(BlockFace.UP).getLocation().add(0.5, 0.0, 0.5);
|
||||
FallingBlock block = ground.getWorld().spawnFallingBlock(loc, ground.getBlock().getBlockData());
|
||||
block.setDropItem(false);
|
||||
block.setVelocity(new Vector(0, 0.4 + i * 0.01, 0));
|
||||
SlimefunPlugin.getUtilities().blocks.add(block.getUniqueId());
|
||||
}
|
||||
for (Entity n: ground.getChunk().getEntities()) {
|
||||
if (n instanceof LivingEntity && n.getLocation().distance(ground) <= 2.0D && !n.getUniqueId().equals(p.getUniqueId())) {
|
||||
Vector vector = n.getLocation().toVector().subtract(p.getLocation().toVector()).normalize().multiply(1.4);
|
||||
vector.setY(0.9);
|
||||
n.setVelocity(vector);
|
||||
|
||||
if (p.getWorld().getPVP()) {
|
||||
EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(p, n, DamageCause.ENTITY_ATTACK, 6D);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) ((LivingEntity) n).damage(6D);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
damageItem(p, item);
|
||||
}
|
||||
|
||||
return true;
|
||||
b.getWorld().playEffect(ground, Effect.STEP_SOUND, ground.getBlock().getType());
|
||||
|
||||
if (ground.getBlock().getRelative(BlockFace.UP).getType() == null || ground.getBlock().getRelative(BlockFace.UP).getType() == Material.AIR) {
|
||||
Location loc = ground.getBlock().getRelative(BlockFace.UP).getLocation().add(0.5, 0.0, 0.5);
|
||||
FallingBlock block = ground.getWorld().spawnFallingBlock(loc, ground.getBlock().getBlockData());
|
||||
block.setDropItem(false);
|
||||
block.setVelocity(new Vector(0, 0.4 + i * 0.01, 0));
|
||||
SlimefunPlugin.getUtilities().blocks.add(block.getUniqueId());
|
||||
}
|
||||
|
||||
for (Entity n : ground.getChunk().getEntities()) {
|
||||
if (n instanceof LivingEntity && n.getLocation().distance(ground) <= 2.0D && !n.getUniqueId().equals(p.getUniqueId())) {
|
||||
Vector vector = n.getLocation().toVector().subtract(p.getLocation().toVector()).normalize().multiply(1.4);
|
||||
vector.setY(0.9);
|
||||
n.setVelocity(vector);
|
||||
|
||||
if (p.getWorld().getPVP()) {
|
||||
EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(p, n, DamageCause.ENTITY_ATTACK, 6D);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) ((LivingEntity) n).damage(6D);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
damageItem(p, e.getItem());
|
||||
}
|
||||
else return false;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@ import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockBreakHandler;
|
||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class SmeltersPickaxe extends SimpleSlimefunItem<BlockBreakHandler> {
|
||||
@ -34,6 +35,7 @@ public class SmeltersPickaxe extends SimpleSlimefunItem<BlockBreakHandler> {
|
||||
if (isItem(item)) {
|
||||
if (BlockStorage.hasBlockInfo(e.getBlock())) return true;
|
||||
if (e.getBlock().getType() == Material.PLAYER_HEAD) return true;
|
||||
if (!Slimefun.hasUnlocked(e.getPlayer(), this, true)) return true;
|
||||
|
||||
Collection<ItemStack> blockDrops = e.getBlock().getDrops(getItem());
|
||||
for (ItemStack drop : blockDrops) {
|
||||
|
@ -0,0 +1,39 @@
|
||||
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemUseHandler;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class Splint extends SimpleSlimefunItem<ItemUseHandler> {
|
||||
|
||||
public Splint(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) {
|
||||
super(category, item, recipeType, recipe, recipeOutput);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemUseHandler getItemHandler() {
|
||||
return e -> {
|
||||
Player p = e.getPlayer();
|
||||
|
||||
if (p.getGameMode() != GameMode.CREATIVE) {
|
||||
ItemUtils.consumeItem(e.getItem(), false);
|
||||
}
|
||||
|
||||
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_SKELETON_HURT, 1, 1);
|
||||
p.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 0));
|
||||
|
||||
e.cancel();
|
||||
};
|
||||
}
|
||||
|
||||
}
|
@ -9,6 +9,7 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
@ -20,10 +21,10 @@ import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemInteractionHandler;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemUseHandler;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class StormStaff extends SimpleSlimefunItem<ItemInteractionHandler> {
|
||||
public class StormStaff extends SimpleSlimefunItem<ItemUseHandler> {
|
||||
|
||||
public static final int MAX_USES = 8;
|
||||
|
||||
@ -46,65 +47,66 @@ public class StormStaff extends SimpleSlimefunItem<ItemInteractionHandler> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemInteractionHandler getItemHandler() {
|
||||
return (e, p, item) -> {
|
||||
if (isItem(item)) {
|
||||
if (!item.hasItemMeta()) return false;
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
if (!itemMeta.hasLore()) return false;
|
||||
List<String> itemLore = itemMeta.getLore();
|
||||
public ItemUseHandler getItemHandler() {
|
||||
return e -> {
|
||||
Player p = e.getPlayer();
|
||||
ItemStack item = e.getItem();
|
||||
|
||||
if (!item.hasItemMeta()) return;
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
if (!itemMeta.hasLore()) return;
|
||||
List<String> itemLore = itemMeta.getLore();
|
||||
|
||||
ItemStack sfItem = getItem();
|
||||
ItemMeta sfItemMeta = sfItem.getItemMeta();
|
||||
List<String> sfItemLore = sfItemMeta.getLore();
|
||||
ItemStack sfItem = getItem();
|
||||
ItemMeta sfItemMeta = sfItem.getItemMeta();
|
||||
List<String> sfItemLore = sfItemMeta.getLore();
|
||||
|
||||
// Index 1 and 3 in SlimefunItems.STAFF_STORM has lores with words and stuff so we check for them.
|
||||
if (itemLore.size() < 6 && itemLore.get(1).equals(sfItemLore.get(1)) && itemLore.get(3).equals(sfItemLore.get(3))) {
|
||||
if (p.getFoodLevel() >= 4 || p.getGameMode() == GameMode.CREATIVE) {
|
||||
// Get a target block with max. 30 blocks of distance
|
||||
Location loc = p.getTargetBlock(null, 30).getLocation();
|
||||
// Index 1 and 3 in SlimefunItems.STAFF_STORM has lores with words and stuff so we check for them.
|
||||
if (itemLore.size() < 6 && itemLore.get(1).equals(sfItemLore.get(1)) && itemLore.get(3).equals(sfItemLore.get(3))) {
|
||||
if (p.getFoodLevel() >= 4 || p.getGameMode() == GameMode.CREATIVE) {
|
||||
// Get a target block with max. 30 blocks of distance
|
||||
Location loc = p.getTargetBlock(null, 30).getLocation();
|
||||
|
||||
if (loc.getWorld() != null && loc.getChunk().isLoaded()) {
|
||||
if (loc.getWorld().getPVP() && SlimefunPlugin.getProtectionManager().hasPermission(p, loc, ProtectableAction.PVP)) {
|
||||
loc.getWorld().strikeLightning(loc);
|
||||
if (loc.getWorld() != null && loc.getChunk().isLoaded()) {
|
||||
if (loc.getWorld().getPVP() && SlimefunPlugin.getProtectionManager().hasPermission(p, loc, ProtectableAction.PVP)) {
|
||||
loc.getWorld().strikeLightning(loc);
|
||||
|
||||
if (p.getInventory().getItemInMainHand().getType() != Material.SHEARS && p.getGameMode() != GameMode.CREATIVE) {
|
||||
FoodLevelChangeEvent event = new FoodLevelChangeEvent(p, p.getFoodLevel() - 4);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
p.setFoodLevel(event.getFoodLevel());
|
||||
}
|
||||
|
||||
int currentUses = itemMeta.getPersistentDataContainer()
|
||||
.getOrDefault(usageKey, PersistentDataType.INTEGER, MAX_USES);
|
||||
|
||||
e.setCancelled(true);
|
||||
if (currentUses == 1) {
|
||||
p.playSound(p.getLocation(), Sound.ENTITY_ITEM_BREAK, 1, 1);
|
||||
item.setAmount(0);
|
||||
}
|
||||
else {
|
||||
itemMeta.getPersistentDataContainer().set(
|
||||
usageKey, PersistentDataType.INTEGER, --currentUses
|
||||
);
|
||||
itemLore.set(4, ChatColor.translateAlternateColorCodes('&',
|
||||
"&e" + currentUses + ' ' + (currentUses > 1 ? "Uses": "Use") + " &7left"));
|
||||
itemMeta.setLore(itemLore);
|
||||
item.setItemMeta(itemMeta);
|
||||
}
|
||||
return true;
|
||||
if (p.getInventory().getItemInMainHand().getType() != Material.SHEARS && p.getGameMode() != GameMode.CREATIVE) {
|
||||
FoodLevelChangeEvent event = new FoodLevelChangeEvent(p, p.getFoodLevel() - 4);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
p.setFoodLevel(event.getFoodLevel());
|
||||
}
|
||||
|
||||
int currentUses = itemMeta.getPersistentDataContainer()
|
||||
.getOrDefault(usageKey, PersistentDataType.INTEGER, MAX_USES);
|
||||
|
||||
e.cancel();
|
||||
if (currentUses == 1) {
|
||||
p.playSound(p.getLocation(), Sound.ENTITY_ITEM_BREAK, 1, 1);
|
||||
item.setAmount(0);
|
||||
}
|
||||
else {
|
||||
SlimefunPlugin.getLocal().sendMessage(p, "messages.no-pvp", true);
|
||||
itemMeta.getPersistentDataContainer().set(
|
||||
usageKey, PersistentDataType.INTEGER, --currentUses
|
||||
);
|
||||
itemLore.set(4, ChatColor.translateAlternateColorCodes('&',
|
||||
"&e" + currentUses + ' ' + (currentUses > 1 ? "Uses": "Use") + " &7left"));
|
||||
itemMeta.setLore(itemLore);
|
||||
item.setItemMeta(itemMeta);
|
||||
}
|
||||
return;
|
||||
}
|
||||
else {
|
||||
SlimefunPlugin.getLocal().sendMessage(p, "messages.no-pvp", true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
SlimefunPlugin.getLocal().sendMessage(p, "messages.hungry", true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
SlimefunPlugin.getLocal().sendMessage(p, "messages.hungry", true);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -9,30 +9,26 @@ import org.bukkit.inventory.ItemStack;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemInteractionHandler;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemUseHandler;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class TelepositionScroll extends SimpleSlimefunItem<ItemInteractionHandler> {
|
||||
public class TelepositionScroll extends SimpleSlimefunItem<ItemUseHandler> {
|
||||
|
||||
public TelepositionScroll(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, item, recipeType, recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemInteractionHandler getItemHandler() {
|
||||
return (e, p, item) -> {
|
||||
if (isItem(item)) {
|
||||
for (Entity n : p.getNearbyEntities(10.0, 10.0, 10.0)) {
|
||||
if (n instanceof LivingEntity && !(n instanceof ArmorStand) && !n.getUniqueId().equals(p.getUniqueId())) {
|
||||
float yaw = n.getLocation().getYaw() + 180.0F;
|
||||
if (yaw > 360.0F) yaw = yaw - 360.0F;
|
||||
|
||||
n.teleport(new Location(n.getWorld(), n.getLocation().getX(), n.getLocation().getY(), n.getLocation().getZ(), yaw, n.getLocation().getPitch()));
|
||||
}
|
||||
public ItemUseHandler getItemHandler() {
|
||||
return e -> {
|
||||
for (Entity n : e.getPlayer().getNearbyEntities(10.0, 10.0, 10.0)) {
|
||||
if (n instanceof LivingEntity && !(n instanceof ArmorStand) && !n.getUniqueId().equals(e.getPlayer().getUniqueId())) {
|
||||
float yaw = n.getLocation().getYaw() + 180.0F;
|
||||
if (yaw > 360.0F) yaw = yaw - 360.0F;
|
||||
|
||||
n.teleport(new Location(n.getWorld(), n.getLocation().getX(), n.getLocation().getY(), n.getLocation().getZ(), yaw, n.getLocation().getPitch()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,49 @@
|
||||
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemUseHandler;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class Vitamins extends SimpleSlimefunItem<ItemUseHandler> {
|
||||
|
||||
public Vitamins(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, item, recipeType, recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemUseHandler getItemHandler() {
|
||||
return e -> {
|
||||
Player p = e.getPlayer();
|
||||
|
||||
if (p.getGameMode() != GameMode.CREATIVE) {
|
||||
ItemUtils.consumeItem(e.getItem(), false);
|
||||
}
|
||||
|
||||
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_GENERIC_EAT, 1, 1);
|
||||
|
||||
if (p.hasPotionEffect(PotionEffectType.POISON)) p.removePotionEffect(PotionEffectType.POISON);
|
||||
if (p.hasPotionEffect(PotionEffectType.WITHER)) p.removePotionEffect(PotionEffectType.WITHER);
|
||||
if (p.hasPotionEffect(PotionEffectType.SLOW)) p.removePotionEffect(PotionEffectType.SLOW);
|
||||
if (p.hasPotionEffect(PotionEffectType.SLOW_DIGGING)) p.removePotionEffect(PotionEffectType.SLOW_DIGGING);
|
||||
if (p.hasPotionEffect(PotionEffectType.WEAKNESS)) p.removePotionEffect(PotionEffectType.WEAKNESS);
|
||||
if (p.hasPotionEffect(PotionEffectType.CONFUSION)) p.removePotionEffect(PotionEffectType.CONFUSION);
|
||||
if (p.hasPotionEffect(PotionEffectType.BLINDNESS)) p.removePotionEffect(PotionEffectType.BLINDNESS);
|
||||
|
||||
p.setFireTicks(0);
|
||||
p.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 2));
|
||||
|
||||
e.cancel();
|
||||
};
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemUseHandler;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class WaterStaff extends SimpleSlimefunItem<ItemUseHandler> {
|
||||
|
||||
public WaterStaff(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, item, recipeType, recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemUseHandler getItemHandler() {
|
||||
return e -> {
|
||||
Player p = e.getPlayer();
|
||||
|
||||
p.setFireTicks(0);
|
||||
SlimefunPlugin.getLocal().sendMessage(p, "messages.fire-extinguish", true);
|
||||
};
|
||||
}
|
||||
|
||||
}
|
@ -5,6 +5,7 @@ import org.bukkit.Effect;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@ -12,36 +13,35 @@ import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemInteractionHandler;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemUseHandler;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class WindStaff extends SimpleSlimefunItem<ItemInteractionHandler> {
|
||||
public class WindStaff extends SimpleSlimefunItem<ItemUseHandler> {
|
||||
|
||||
public WindStaff(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, item, recipeType, recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemInteractionHandler getItemHandler() {
|
||||
return (e, p, item) -> {
|
||||
if (isItem(item)) {
|
||||
if (p.getFoodLevel() >= 2) {
|
||||
if (p.getInventory().getItemInMainHand().getType() != Material.SHEARS && p.getGameMode() != GameMode.CREATIVE) {
|
||||
FoodLevelChangeEvent event = new FoodLevelChangeEvent(p, p.getFoodLevel() - 2);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
p.setFoodLevel(event.getFoodLevel());
|
||||
}
|
||||
p.setVelocity(p.getEyeLocation().getDirection().multiply(4));
|
||||
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_TNT_PRIMED, 1, 1);
|
||||
p.getWorld().playEffect(p.getLocation(), Effect.SMOKE, 1);
|
||||
p.setFallDistance(0F);
|
||||
public ItemUseHandler getItemHandler() {
|
||||
return e -> {
|
||||
Player p = e.getPlayer();
|
||||
|
||||
if (p.getFoodLevel() >= 2) {
|
||||
if (p.getInventory().getItemInMainHand().getType() != Material.SHEARS && p.getGameMode() != GameMode.CREATIVE) {
|
||||
FoodLevelChangeEvent event = new FoodLevelChangeEvent(p, p.getFoodLevel() - 2);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
p.setFoodLevel(event.getFoodLevel());
|
||||
}
|
||||
else {
|
||||
SlimefunPlugin.getLocal().sendMessage(p, "messages.hungry", true);
|
||||
}
|
||||
return true;
|
||||
|
||||
p.setVelocity(p.getEyeLocation().getDirection().multiply(4));
|
||||
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_TNT_PRIMED, 1, 1);
|
||||
p.getWorld().playEffect(p.getLocation(), Effect.SMOKE, 1);
|
||||
p.setFallDistance(0F);
|
||||
}
|
||||
else {
|
||||
SlimefunPlugin.getLocal().sendMessage(p, "messages.hungry", true);
|
||||
}
|
||||
else return false;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Material;
|
||||
@ -13,15 +14,12 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections;
|
||||
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.events.ItemUseEvent;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunGadget;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemInteractionHandler;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockUseHandler;
|
||||
import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;
|
||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
@ -58,50 +56,41 @@ public class Composter extends SlimefunGadget {
|
||||
|
||||
@Override
|
||||
public void preRegister() {
|
||||
addItemHandler(new ItemInteractionHandler() {
|
||||
addItemHandler((BlockUseHandler) e -> {
|
||||
Optional<Block> block = e.getClickedBlock();
|
||||
|
||||
if (block.isPresent()) {
|
||||
Player p = e.getPlayer();
|
||||
Block b = block.get();
|
||||
|
||||
if (p.hasPermission("slimefun.inventory.bypass") || SlimefunPlugin.getProtectionManager().hasPermission(p, b.getLocation(), ProtectableAction.ACCESS_INVENTORIES)) {
|
||||
ItemStack input = e.getItem();
|
||||
|
||||
for (ItemStack convert : RecipeType.getRecipeInputs(Composter.this)) {
|
||||
if (convert != null && SlimefunManager.isItemSimilar(input, convert, true)) {
|
||||
ItemStack removing = input.clone();
|
||||
removing.setAmount(convert.getAmount());
|
||||
p.getInventory().removeItem(removing);
|
||||
ItemStack adding = RecipeType.getRecipeOutput(Composter.this, convert);
|
||||
|
||||
@Override
|
||||
public boolean onRightClick(ItemUseEvent e, final Player p, ItemStack item) {
|
||||
if (e.getClickedBlock() != null) {
|
||||
String id = BlockStorage.checkID(e.getClickedBlock());
|
||||
if (id != null && id.equals(getID())) {
|
||||
if (p.hasPermission("slimefun.inventory.bypass") || SlimefunPlugin.getProtectionManager().hasPermission(p, e.getClickedBlock().getLocation(), ProtectableAction.ACCESS_INVENTORIES)) {
|
||||
ItemStack input = p.getInventory().getItemInMainHand();
|
||||
Block b = e.getClickedBlock();
|
||||
SlimefunItem machine = SlimefunItem.getByID(id);
|
||||
|
||||
for (ItemStack convert : RecipeType.getRecipeInputs(machine)) {
|
||||
if (convert != null && SlimefunManager.isItemSimilar(input, convert, true)) {
|
||||
ItemStack removing = input.clone();
|
||||
removing.setAmount(convert.getAmount());
|
||||
p.getInventory().removeItem(removing);
|
||||
ItemStack adding = RecipeType.getRecipeOutput(machine, convert);
|
||||
|
||||
for (int i = 1; i < 12; i++) {
|
||||
int j = i;
|
||||
|
||||
Slimefun.runSync(() -> {
|
||||
if (j < 11) {
|
||||
b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, input.getType().isBlock() ? input.getType() : Material.HAY_BLOCK);
|
||||
}
|
||||
else {
|
||||
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F);
|
||||
b.getWorld().dropItemNaturally(b.getRelative(BlockFace.UP).getLocation(), adding);
|
||||
}
|
||||
}, i * 30L);
|
||||
for (int i = 1; i < 12; i++) {
|
||||
int j = i;
|
||||
|
||||
Slimefun.runSync(() -> {
|
||||
if (j < 11) {
|
||||
b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, input.getType().isBlock() ? input.getType() : Material.HAY_BLOCK);
|
||||
}
|
||||
else {
|
||||
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F);
|
||||
b.getWorld().dropItemNaturally(b.getRelative(BlockFace.UP).getLocation(), adding);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}, i * 30L);
|
||||
}
|
||||
|
||||
SlimefunPlugin.getLocal().sendMessage(p, "machines.wrong-item", true);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
SlimefunPlugin.getLocal().sendMessage(p, "machines.wrong-item", true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
@ -10,6 +11,7 @@ import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.Levelled;
|
||||
import org.bukkit.block.data.Waterlogged;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections;
|
||||
@ -18,8 +20,7 @@ import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunGadget;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemInteractionHandler;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockUseHandler;
|
||||
import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;
|
||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||
@ -61,87 +62,83 @@ public class Crucible extends SlimefunGadget {
|
||||
|
||||
@Override
|
||||
public void preRegister() {
|
||||
addItemHandler((ItemInteractionHandler) (e, p, item) -> {
|
||||
if (e.getClickedBlock() != null) {
|
||||
String id = BlockStorage.checkID(e.getClickedBlock());
|
||||
addItemHandler((BlockUseHandler) e -> {
|
||||
Optional<Block> optional = e.getClickedBlock();
|
||||
|
||||
if (optional.isPresent()) {
|
||||
Player p = e.getPlayer();
|
||||
Block b = optional.get();
|
||||
|
||||
if (id != null && id.equals("CRUCIBLE")) {
|
||||
if (p.hasPermission("slimefun.inventory.bypass") || SlimefunPlugin.getProtectionManager().hasPermission(p, e.getClickedBlock().getLocation(), ProtectableAction.ACCESS_INVENTORIES)) {
|
||||
ItemStack input = p.getInventory().getItemInMainHand();
|
||||
Block block = e.getClickedBlock().getRelative(BlockFace.UP);
|
||||
SlimefunItem machine = SlimefunItem.getByID(id);
|
||||
if (p.hasPermission("slimefun.inventory.bypass") || SlimefunPlugin.getProtectionManager().hasPermission(p, b.getLocation(), ProtectableAction.ACCESS_INVENTORIES)) {
|
||||
ItemStack input = e.getItem();
|
||||
Block block = b.getRelative(BlockFace.UP);
|
||||
|
||||
for (ItemStack convert : RecipeType.getRecipeInputs(machine)) {
|
||||
if (SlimefunManager.isItemSimilar(input, convert, true)) {
|
||||
e.setCancelled(true);
|
||||
for (ItemStack convert : RecipeType.getRecipeInputs(Crucible.this)) {
|
||||
if (SlimefunManager.isItemSimilar(input, convert, true)) {
|
||||
e.cancel();
|
||||
|
||||
ItemStack removing = input.clone();
|
||||
removing.setAmount(convert.getAmount());
|
||||
p.getInventory().removeItem(removing);
|
||||
ItemStack removing = input.clone();
|
||||
removing.setAmount(convert.getAmount());
|
||||
p.getInventory().removeItem(removing);
|
||||
|
||||
boolean water = Tag.LEAVES.isTagged(input.getType());
|
||||
boolean water = Tag.LEAVES.isTagged(input.getType());
|
||||
|
||||
if (block.getType() == (water ? Material.WATER : Material.LAVA)) {
|
||||
int level = ((Levelled) block.getBlockData()).getLevel();
|
||||
|
||||
if (block.getType() == (water ? Material.WATER : Material.LAVA)) {
|
||||
int level = ((Levelled) block.getBlockData()).getLevel();
|
||||
|
||||
if (level > 7) {
|
||||
level -= 8;
|
||||
}
|
||||
|
||||
if (level == 0) {
|
||||
block.getWorld().playSound(block.getLocation(), water ? Sound.ENTITY_PLAYER_SPLASH : Sound.BLOCK_LAVA_POP, 1F, 1F);
|
||||
}
|
||||
else {
|
||||
int finalLevel = 7 - level;
|
||||
Slimefun.runSync(() -> runPostTask(block, water ? Sound.ENTITY_PLAYER_SPLASH : Sound.BLOCK_LAVA_POP, finalLevel), 50L);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (block.getType() == (water ? Material.LAVA : Material.WATER)) {
|
||||
int level = ((Levelled) block.getBlockData()).getLevel();
|
||||
block.setType(level == 0 || level == 8 ? Material.OBSIDIAN : Material.STONE);
|
||||
block.getWorld().playSound(block.getLocation(), Sound.BLOCK_LAVA_EXTINGUISH, 1F, 1F);
|
||||
return true;
|
||||
if (level > 7) {
|
||||
level -= 8;
|
||||
}
|
||||
|
||||
if (level == 0) {
|
||||
block.getWorld().playSound(block.getLocation(), water ? Sound.ENTITY_PLAYER_SPLASH : Sound.BLOCK_LAVA_POP, 1F, 1F);
|
||||
}
|
||||
else {
|
||||
int finalLevel = 7 - level;
|
||||
Slimefun.runSync(() -> runPostTask(block, water ? Sound.ENTITY_PLAYER_SPLASH : Sound.BLOCK_LAVA_POP, finalLevel), 50L);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
else if (block.getType() == (water ? Material.LAVA : Material.WATER)) {
|
||||
int level = ((Levelled) block.getBlockData()).getLevel();
|
||||
block.setType(level == 0 || level == 8 ? Material.OBSIDIAN : Material.STONE);
|
||||
block.getWorld().playSound(block.getLocation(), Sound.BLOCK_LAVA_EXTINGUISH, 1F, 1F);
|
||||
return;
|
||||
}
|
||||
|
||||
Slimefun.runSync(() -> {
|
||||
if (block.getType() == Material.AIR || block.getType() == Material.CAVE_AIR || block.getType() == Material.VOID_AIR) {
|
||||
if (water) {
|
||||
if (block.getBlockData() instanceof Waterlogged) {
|
||||
Waterlogged wl = (Waterlogged) block.getBlockData();
|
||||
wl.setWaterlogged(true);
|
||||
block.setBlockData(wl, false);
|
||||
block.getWorld().playSound(block.getLocation(), Sound.ENTITY_PLAYER_SPLASH, 1F, 1F);
|
||||
return;
|
||||
}
|
||||
|
||||
block.getWorld().playSound(block.getLocation(), Sound.BLOCK_METAL_BREAK, 1F, 1F);
|
||||
Slimefun.runSync(() -> {
|
||||
if (block.getType() == Material.AIR || block.getType() == Material.CAVE_AIR || block.getType() == Material.VOID_AIR) {
|
||||
if (water) {
|
||||
if (block.getBlockData() instanceof Waterlogged) {
|
||||
Waterlogged wl = (Waterlogged) block.getBlockData();
|
||||
wl.setWaterlogged(true);
|
||||
block.setBlockData(wl, false);
|
||||
block.getWorld().playSound(block.getLocation(), Sound.ENTITY_PLAYER_SPLASH, 1F, 1F);
|
||||
return;
|
||||
}
|
||||
|
||||
if (BlockStorage.hasBlockInfo(block)) {
|
||||
BlockStorage.clearBlockInfo(block);
|
||||
}
|
||||
|
||||
block.getWorld().playSound(block.getLocation(), Sound.BLOCK_LAVA_EXTINGUISH, 1F, 1F);
|
||||
block.getWorld().playSound(block.getLocation(), Sound.BLOCK_METAL_BREAK, 1F, 1F);
|
||||
return;
|
||||
}
|
||||
|
||||
block.setType(water ? Material.WATER : Material.LAVA);
|
||||
runPostTask(block, water ? Sound.ENTITY_PLAYER_SPLASH : Sound.BLOCK_LAVA_POP, 1);
|
||||
}, 50L);
|
||||
|
||||
return true;
|
||||
}
|
||||
if (BlockStorage.hasBlockInfo(block)) {
|
||||
BlockStorage.clearBlockInfo(block);
|
||||
}
|
||||
|
||||
block.getWorld().playSound(block.getLocation(), Sound.BLOCK_LAVA_EXTINGUISH, 1F, 1F);
|
||||
}
|
||||
|
||||
block.setType(water ? Material.WATER : Material.LAVA);
|
||||
runPostTask(block, water ? Sound.ENTITY_PLAYER_SPLASH : Sound.BLOCK_LAVA_POP, 1);
|
||||
|
||||
}, 50L);
|
||||
}
|
||||
|
||||
SlimefunPlugin.getLocal().sendMessage(p, "machines.wrong-item", true);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
|
||||
SlimefunPlugin.getLocal().sendMessage(p, "machines.wrong-item", true);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -20,11 +20,11 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.UnregisterReason;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemInteractionHandler;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockUseHandler;
|
||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class HologramProjector extends SimpleSlimefunItem<ItemInteractionHandler> {
|
||||
public class HologramProjector extends SimpleSlimefunItem<BlockUseHandler> {
|
||||
|
||||
public HologramProjector(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) {
|
||||
super(category, item, recipeType, recipe, recipeOutput);
|
||||
@ -54,22 +54,16 @@ public class HologramProjector extends SimpleSlimefunItem<ItemInteractionHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemInteractionHandler getItemHandler() {
|
||||
return (e, p, item) -> {
|
||||
if (e.getClickedBlock() == null) return false;
|
||||
public BlockUseHandler getItemHandler() {
|
||||
return e -> {
|
||||
e.cancel();
|
||||
|
||||
String id = BlockStorage.checkID(e.getClickedBlock());
|
||||
if (id != null && id.equals(getID())) {
|
||||
e.setCancelled(true);
|
||||
|
||||
if (BlockStorage.getLocationInfo(e.getClickedBlock().getLocation(), "owner").equals(p.getUniqueId().toString())) {
|
||||
openEditor(p, e.getClickedBlock());
|
||||
}
|
||||
|
||||
return true;
|
||||
Player p = e.getPlayer();
|
||||
Block b = e.getClickedBlock().get();
|
||||
|
||||
if (BlockStorage.getLocationInfo(b.getLocation(), "owner").equals(p.getUniqueId().toString())) {
|
||||
openEditor(p, b);
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -7,11 +7,10 @@ import me.mrCookieSlime.Slimefun.GEO.GEOScanner;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemInteractionHandler;
|
||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockUseHandler;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class GEOScannerBlock extends SimpleSlimefunItem<ItemInteractionHandler> {
|
||||
public class GEOScannerBlock extends SimpleSlimefunItem<BlockUseHandler> {
|
||||
|
||||
public GEOScannerBlock(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, item, recipeType, recipe);
|
||||
@ -23,17 +22,12 @@ public class GEOScannerBlock extends SimpleSlimefunItem<ItemInteractionHandler>
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemInteractionHandler getItemHandler() {
|
||||
return (e, p, stack) -> {
|
||||
Block b = e.getClickedBlock();
|
||||
public BlockUseHandler getItemHandler() {
|
||||
return e -> {
|
||||
Block b = e.getClickedBlock().get();
|
||||
|
||||
if (b == null) return false;
|
||||
String item = BlockStorage.checkID(b);
|
||||
if (item == null || !item.equals(getID())) return false;
|
||||
e.setCancelled(true);
|
||||
|
||||
GEOScanner.scanChunk(p, b.getChunk());
|
||||
return true;
|
||||
e.cancel();
|
||||
GEOScanner.scanChunk(e.getPlayer(), b.getChunk());
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -28,11 +28,11 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.UnregisterReason;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemInteractionHandler;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockUseHandler;
|
||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class ElevatorPlate extends SimpleSlimefunItem<ItemInteractionHandler> {
|
||||
public class ElevatorPlate extends SimpleSlimefunItem<BlockUseHandler> {
|
||||
|
||||
private final Set<UUID> users = new HashSet<>();
|
||||
|
||||
@ -64,19 +64,13 @@ public class ElevatorPlate extends SimpleSlimefunItem<ItemInteractionHandler> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemInteractionHandler getItemHandler() {
|
||||
return (e, p, item) -> {
|
||||
Block b = e.getClickedBlock();
|
||||
if (b == null) return false;
|
||||
|
||||
String id = BlockStorage.checkID(b);
|
||||
if (id == null || !id.equals(getID())) return false;
|
||||
public BlockUseHandler getItemHandler() {
|
||||
return e -> {
|
||||
Block b = e.getClickedBlock().get();
|
||||
|
||||
if (BlockStorage.getLocationInfo(b.getLocation(), "owner").equals(p.getUniqueId().toString())) {
|
||||
openEditor(p, b);
|
||||
if (BlockStorage.getLocationInfo(b.getLocation(), "owner").equals(e.getPlayer().getUniqueId().toString())) {
|
||||
openEditor(e.getPlayer(), b);
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,22 @@
|
||||
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.gps;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockUseHandler;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class GPSControlPanel extends SimpleSlimefunItem<BlockUseHandler> {
|
||||
|
||||
public GPSControlPanel(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, item, recipeType, recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockUseHandler getItemHandler() {
|
||||
return e -> SlimefunPlugin.getGPSNetwork().openTransmitterControlPanel(e.getPlayer());
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
import me.mrCookieSlime.Slimefun.GPS.NetworkStatus;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
@ -17,12 +18,13 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.UnregisterReason;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker;
|
||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
import me.mrCookieSlime.Slimefun.api.energy.ChargableBlock;
|
||||
|
||||
public abstract class GPSTransmitter extends SimpleSlimefunItem<BlockTicker> {
|
||||
|
||||
public GPSTransmitter(Category category, ItemStack item, String id, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, item, id, recipeType, recipe);
|
||||
public GPSTransmitter(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, item, recipeType, recipe);
|
||||
|
||||
SlimefunItem.registerBlockHandler(getID(), new SlimefunBlockHandler() {
|
||||
|
||||
@ -49,12 +51,13 @@ public abstract class GPSTransmitter extends SimpleSlimefunItem<BlockTicker> {
|
||||
@Override
|
||||
public void tick(Block b, SlimefunItem item, Config data) {
|
||||
int charge = ChargableBlock.getCharge(b);
|
||||
|
||||
if (charge >= getEnergyConsumption()) {
|
||||
Slimefun.getGPSNetwork().updateTransmitter(b.getLocation(), UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner")), NetworkStatus.ONLINE);
|
||||
SlimefunPlugin.getGPSNetwork().updateTransmitter(b.getLocation(), UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner")), NetworkStatus.ONLINE);
|
||||
ChargableBlock.setCharge(b.getLocation(), charge - getEnergyConsumption());
|
||||
}
|
||||
else {
|
||||
Slimefun.getGPSNetwork().updateTransmitter(b.getLocation(), UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner")), NetworkStatus.OFFLINE);
|
||||
SlimefunPlugin.getGPSNetwork().updateTransmitter(b.getLocation(), UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner")), NetworkStatus.OFFLINE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,15 @@
|
||||
package me.mrCookieSlime.Slimefun.Objects.handlers;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.events.ItemUseEvent;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface BlockUseHandler extends ItemHandler {
|
||||
|
||||
void onRightClick(ItemUseEvent e);
|
||||
|
||||
@Override
|
||||
default Class<? extends ItemHandler> getIdentifier() {
|
||||
return BlockUseHandler.class;
|
||||
}
|
||||
|
||||
}
|
@ -7,7 +7,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
@FunctionalInterface
|
||||
public interface ItemConsumptionHandler extends ItemHandler {
|
||||
|
||||
boolean onConsume(PlayerItemConsumeEvent e, Player p, ItemStack item);
|
||||
void onConsume(PlayerItemConsumeEvent e, Player p, ItemStack item);
|
||||
|
||||
@Override
|
||||
default Class<? extends ItemHandler> getIdentifier() {
|
||||
|
@ -1,10 +1,16 @@
|
||||
package me.mrCookieSlime.Slimefun.Objects.handlers;
|
||||
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.events.ItemUseEvent;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.events.ItemUseEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @deprecated Please use {@link ItemUseHandler} and {@link BlockUseHandler} now.
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
@FunctionalInterface
|
||||
public interface ItemInteractionHandler extends ItemHandler {
|
||||
|
||||
|
@ -0,0 +1,15 @@
|
||||
package me.mrCookieSlime.Slimefun.Objects.handlers;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.events.ItemUseEvent;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface ItemUseHandler extends ItemHandler {
|
||||
|
||||
void onRightClick(ItemUseEvent e);
|
||||
|
||||
@Override
|
||||
default Class<? extends ItemHandler> getIdentifier() {
|
||||
return ItemUseHandler.class;
|
||||
}
|
||||
|
||||
}
|
@ -218,10 +218,19 @@ public final class MiscSetup {
|
||||
handler.run(pre, init, post);
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.GREEN + "###################### - Slimefun - ######################");
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(ChatColor.GREEN + "######################### - Slimefun v" + SlimefunPlugin.getVersion() + " - #########################");
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(ChatColor.GREEN + "Successfully loaded " + SlimefunItem.list().size() + " Items (" + Research.list().size() + " Researches)");
|
||||
sender.sendMessage(ChatColor.GREEN + "( " + SlimefunPlugin.getUtilities().vanillaItems + " Items from Slimefun, " + (SlimefunItem.list().size() - SlimefunPlugin.getUtilities().vanillaItems) + " Items from Addons )");
|
||||
sender.sendMessage(ChatColor.GREEN + "##########################################################");
|
||||
sender.sendMessage(ChatColor.GREEN + "( " + SlimefunPlugin.getUtilities().vanillaItems + " Items from Slimefun, " + (SlimefunItem.list().size() - SlimefunPlugin.getUtilities().vanillaItems) + " Items from " + Slimefun.getInstalledAddons().size() + " Addons )");
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(ChatColor.GREEN + "Slimefun is an Open-Source project that is maintained by community developers!");
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(ChatColor.GREEN + " -- Source Code: https://github.com/TheBusyBiscuit/Slimefun4");
|
||||
sender.sendMessage(ChatColor.GREEN + " -- Wiki: https://github.com/TheBusyBiscuit/Slimefun4/wiki");
|
||||
sender.sendMessage(ChatColor.GREEN + " -- Bug Reports: https://github.com/TheBusyBiscuit/Slimefun4/issues");
|
||||
sender.sendMessage(ChatColor.GREEN + " -- Discord: https://discord.gg/fsD4Bkh");
|
||||
sender.sendMessage("");
|
||||
|
||||
SlimefunPlugin.getItemCfg().save();
|
||||
SlimefunPlugin.getResearchCfg().save();
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.mrCookieSlime.Slimefun.Setup;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.stream.Collectors;
|
||||
@ -20,22 +21,20 @@ import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerItemConsumeEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
||||
import io.github.thebusybiscuit.cscorelib2.inventory.InvUtils;
|
||||
import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils;
|
||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||
import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections;
|
||||
import io.github.thebusybiscuit.cscorelib2.skull.SkullItem;
|
||||
import io.github.thebusybiscuit.slimefun4.api.events.ItemUseEvent;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.FireworkUtils;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.events.ItemUseEvent;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
import me.mrCookieSlime.Slimefun.Lists.Categories;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
@ -62,9 +61,11 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.Talisman;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.UnregisterReason;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.VanillaItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.cargo.AdvancedCargoOutputNode;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.cargo.CargoConnector;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.cargo.CargoInputNode;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.cargo.CargoManagerBlock;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.cargo.CargoOutputNode;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items.Bandage;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items.DietCookie;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items.EnderBackpack;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items.ExplosivePickaxe;
|
||||
@ -81,6 +82,7 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items.LumberAxe;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items.MagicEyeOfEnder;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items.MagicSugar;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items.MeatJerky;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items.Medicine;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items.MonsterJerky;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items.Multimeter;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items.NetherGoldPan;
|
||||
@ -90,13 +92,17 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items.PickaxeOfVeinMining;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items.PortableCrafter;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items.PortableDustbin;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items.PortableGEOScanner;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items.Rag;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items.SeismicAxe;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items.SmeltersPickaxe;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items.SolarHelmet;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items.SoulboundRune;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items.Splint;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items.StormStaff;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items.SwordOfBeheading;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items.TelepositionScroll;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items.Vitamins;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items.WaterStaff;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items.WindStaff;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.AncientPedestal;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.BlockPlacer;
|
||||
@ -145,6 +151,7 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.geo.GEOM
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.geo.GEOScannerBlock;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.geo.OilPump;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.gps.ElevatorPlate;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.gps.GPSControlPanel;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.gps.GPSTransmitter;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.gps.Teleporter;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.reactors.NetherStarReactor;
|
||||
@ -163,8 +170,7 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.multiblocks.Smeltery;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.multiblocks.TableSaw;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockPlaceHandler;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.BowShootHandler;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemConsumptionHandler;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemInteractionHandler;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemUseHandler;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.MultiBlockInteractionHandler;
|
||||
import me.mrCookieSlime.Slimefun.Objects.tasks.RainbowTicker;
|
||||
import me.mrCookieSlime.Slimefun.androids.AndroidType;
|
||||
@ -172,7 +178,6 @@ import me.mrCookieSlime.Slimefun.androids.ProgrammableAndroid;
|
||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
import me.mrCookieSlime.Slimefun.api.item_transport.CargoNet;
|
||||
|
||||
public final class SlimefunSetup {
|
||||
|
||||
@ -610,20 +615,9 @@ public final class SlimefunSetup {
|
||||
new ItemStack[] {null, new ItemStack(Material.FEATHER), SlimefunItems.ENDER_LUMP_3, null, SlimefunItems.STAFF_ELEMENTAL, new ItemStack(Material.FEATHER), SlimefunItems.STAFF_ELEMENTAL, null, null})
|
||||
.register(true);
|
||||
|
||||
new SlimefunItem(Categories.MAGIC, (SlimefunItemStack) SlimefunItems.STAFF_WATER, RecipeType.MAGIC_WORKBENCH,
|
||||
new WaterStaff(Categories.MAGIC, (SlimefunItemStack) SlimefunItems.STAFF_WATER, RecipeType.MAGIC_WORKBENCH,
|
||||
new ItemStack[] {null, new ItemStack(Material.LILY_PAD), SlimefunItems.MAGIC_LUMP_2, null, SlimefunItems.STAFF_ELEMENTAL, new ItemStack(Material.LILY_PAD), SlimefunItems.STAFF_ELEMENTAL, null, null})
|
||||
.register(true, new ItemInteractionHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onRightClick(ItemUseEvent e, Player p, ItemStack item) {
|
||||
if (SlimefunManager.isItemSimilar(item, SlimefunItems.STAFF_WATER, true)) {
|
||||
p.setFireTicks(0);
|
||||
SlimefunPlugin.getLocal().sendMessage(p, "messages.fire-extinguish", true);
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
});
|
||||
.register(true);
|
||||
|
||||
String[] multiToolItems = new String[] {"PORTABLE_CRAFTER", "MAGIC_EYE_OF_ENDER", "STAFF_ELEMENTAL_WIND", "GRAPPLING_HOOK"};
|
||||
|
||||
@ -896,109 +890,32 @@ public final class SlimefunSetup {
|
||||
new ItemStack[] {new ItemStack(Material.WHITE_WOOL), null, null, null, null, null, null, null, null}, new CustomItem(SlimefunItems.CLOTH, 8))
|
||||
.register(true);
|
||||
|
||||
new SlimefunItem(Categories.PORTABLE, (SlimefunItemStack) SlimefunItems.RAG, RecipeType.ENHANCED_CRAFTING_TABLE,
|
||||
new Rag(Categories.PORTABLE, (SlimefunItemStack) SlimefunItems.RAG, RecipeType.ENHANCED_CRAFTING_TABLE,
|
||||
new ItemStack[] {SlimefunItems.CLOTH, SlimefunItems.CLOTH, SlimefunItems.CLOTH, new ItemStack(Material.STRING), null, new ItemStack(Material.STRING), SlimefunItems.CLOTH, SlimefunItems.CLOTH, SlimefunItems.CLOTH})
|
||||
.register(true, new ItemInteractionHandler() {
|
||||
.register(true);
|
||||
|
||||
@Override
|
||||
public boolean onRightClick(ItemUseEvent e, Player p, ItemStack item) {
|
||||
if (SlimefunManager.isItemSimilar(item, SlimefunItems.RAG, true)) {
|
||||
if (p.getGameMode() != GameMode.CREATIVE) ItemUtils.consumeItem(item, false);
|
||||
p.getWorld().playEffect(p.getLocation(), Effect.STEP_SOUND, Material.WHITE_WOOL);
|
||||
p.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 0));
|
||||
p.setFireTicks(0);
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
});
|
||||
|
||||
new SlimefunItem(Categories.PORTABLE, (SlimefunItemStack) SlimefunItems.BANDAGE, RecipeType.ENHANCED_CRAFTING_TABLE,
|
||||
new Bandage(Categories.PORTABLE, (SlimefunItemStack) SlimefunItems.BANDAGE, RecipeType.ENHANCED_CRAFTING_TABLE,
|
||||
new ItemStack[] {SlimefunItems.RAG, new ItemStack(Material.STRING), SlimefunItems.RAG, null, null, null, null, null, null},
|
||||
new CustomItem(SlimefunItems.BANDAGE, 4))
|
||||
.register(true, new ItemInteractionHandler() {
|
||||
.register(true);
|
||||
|
||||
@Override
|
||||
public boolean onRightClick(ItemUseEvent e, Player p, ItemStack item) {
|
||||
if (SlimefunManager.isItemSimilar(item, SlimefunItems.BANDAGE, true)) {
|
||||
if (p.getGameMode() != GameMode.CREATIVE) ItemUtils.consumeItem(item, false);
|
||||
p.getWorld().playEffect(p.getLocation(), Effect.STEP_SOUND, Material.WHITE_WOOL);
|
||||
p.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 1));
|
||||
p.setFireTicks(0);
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
});
|
||||
|
||||
new SlimefunItem(Categories.PORTABLE, (SlimefunItemStack) SlimefunItems.SPLINT, RecipeType.ENHANCED_CRAFTING_TABLE,
|
||||
new Splint(Categories.PORTABLE, (SlimefunItemStack) SlimefunItems.SPLINT, RecipeType.ENHANCED_CRAFTING_TABLE,
|
||||
new ItemStack[] {null, new ItemStack(Material.IRON_INGOT), null, new ItemStack(Material.STICK), new ItemStack(Material.STICK), new ItemStack(Material.STICK), null, new ItemStack(Material.IRON_INGOT), null},
|
||||
new CustomItem(SlimefunItems.SPLINT, 4))
|
||||
.register(true, new ItemInteractionHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onRightClick(ItemUseEvent e, Player p, ItemStack item) {
|
||||
if (SlimefunManager.isItemSimilar(item, SlimefunItems.SPLINT, true)) {
|
||||
if (p.getGameMode() != GameMode.CREATIVE) ItemUtils.consumeItem(item, false);
|
||||
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_SKELETON_HURT, 1, 1);
|
||||
p.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 0));
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
});
|
||||
.register(true);
|
||||
|
||||
new SlimefunItem(Categories.MISC, (SlimefunItemStack) SlimefunItems.CAN, RecipeType.ENHANCED_CRAFTING_TABLE,
|
||||
new ItemStack[] {SlimefunItems.TIN_INGOT, SlimefunItems.TIN_INGOT, SlimefunItems.TIN_INGOT, SlimefunItems.TIN_INGOT, null, SlimefunItems.TIN_INGOT, SlimefunItems.TIN_INGOT, SlimefunItems.TIN_INGOT, SlimefunItems.TIN_INGOT},
|
||||
new CustomItem(SlimefunItems.CAN, 4))
|
||||
.register(true);
|
||||
|
||||
new SlimefunItem(Categories.PORTABLE, (SlimefunItemStack) SlimefunItems.VITAMINS, RecipeType.ENHANCED_CRAFTING_TABLE,
|
||||
new Vitamins(Categories.PORTABLE, (SlimefunItemStack) SlimefunItems.VITAMINS, RecipeType.ENHANCED_CRAFTING_TABLE,
|
||||
new ItemStack[] {SlimefunItems.CAN, new ItemStack(Material.APPLE), new ItemStack(Material.RED_MUSHROOM), new ItemStack(Material.SUGAR), null, null, null, null, null})
|
||||
.register(true, new ItemInteractionHandler() {
|
||||
.register(true);
|
||||
|
||||
@Override
|
||||
public boolean onRightClick(ItemUseEvent e, Player p, ItemStack item) {
|
||||
if (SlimefunManager.isItemSimilar(item, SlimefunItems.VITAMINS, true)) {
|
||||
if (p.getGameMode() != GameMode.CREATIVE) ItemUtils.consumeItem(item, false);
|
||||
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_GENERIC_EAT, 1, 1);
|
||||
if (p.hasPotionEffect(PotionEffectType.POISON)) p.removePotionEffect(PotionEffectType.POISON);
|
||||
if (p.hasPotionEffect(PotionEffectType.WITHER)) p.removePotionEffect(PotionEffectType.WITHER);
|
||||
if (p.hasPotionEffect(PotionEffectType.SLOW)) p.removePotionEffect(PotionEffectType.SLOW);
|
||||
if (p.hasPotionEffect(PotionEffectType.SLOW_DIGGING)) p.removePotionEffect(PotionEffectType.SLOW_DIGGING);
|
||||
if (p.hasPotionEffect(PotionEffectType.WEAKNESS)) p.removePotionEffect(PotionEffectType.WEAKNESS);
|
||||
if (p.hasPotionEffect(PotionEffectType.CONFUSION)) p.removePotionEffect(PotionEffectType.CONFUSION);
|
||||
if (p.hasPotionEffect(PotionEffectType.BLINDNESS)) p.removePotionEffect(PotionEffectType.BLINDNESS);
|
||||
p.setFireTicks(0);
|
||||
p.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 2));
|
||||
e.setCancelled(true);
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
});
|
||||
|
||||
new SlimefunItem(Categories.PORTABLE, (SlimefunItemStack) SlimefunItems.MEDICINE, RecipeType.ENHANCED_CRAFTING_TABLE,
|
||||
new Medicine(Categories.PORTABLE, (SlimefunItemStack) SlimefunItems.MEDICINE, RecipeType.ENHANCED_CRAFTING_TABLE,
|
||||
new ItemStack[] {SlimefunItems.VITAMINS, new ItemStack(Material.GLASS_BOTTLE), SlimefunItems.HEAVY_CREAM, null, null, null, null, null, null})
|
||||
.register(true, new ItemConsumptionHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onConsume(PlayerItemConsumeEvent e, Player p, ItemStack item) {
|
||||
if (SlimefunManager.isItemSimilar(item, SlimefunItems.MEDICINE, true)) {
|
||||
if (p.hasPotionEffect(PotionEffectType.POISON)) p.removePotionEffect(PotionEffectType.POISON);
|
||||
if (p.hasPotionEffect(PotionEffectType.WITHER)) p.removePotionEffect(PotionEffectType.WITHER);
|
||||
if (p.hasPotionEffect(PotionEffectType.SLOW)) p.removePotionEffect(PotionEffectType.SLOW);
|
||||
if (p.hasPotionEffect(PotionEffectType.SLOW_DIGGING)) p.removePotionEffect(PotionEffectType.SLOW_DIGGING);
|
||||
if (p.hasPotionEffect(PotionEffectType.WEAKNESS)) p.removePotionEffect(PotionEffectType.WEAKNESS);
|
||||
if (p.hasPotionEffect(PotionEffectType.CONFUSION)) p.removePotionEffect(PotionEffectType.CONFUSION);
|
||||
if (p.hasPotionEffect(PotionEffectType.BLINDNESS)) p.removePotionEffect(PotionEffectType.BLINDNESS);
|
||||
|
||||
p.setFireTicks(0);
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
});
|
||||
.register(true);
|
||||
|
||||
new SlimefunArmorPiece(Categories.TECH, (SlimefunItemStack) SlimefunItems.NIGHT_VISION_GOGGLES, RecipeType.ARMOR_FORGE,
|
||||
new ItemStack[] {new ItemStack(Material.COAL_BLOCK), new ItemStack(Material.COAL_BLOCK), new ItemStack(Material.COAL_BLOCK), new ItemStack(Material.LIME_STAINED_GLASS_PANE), new ItemStack(Material.COAL_BLOCK), new ItemStack(Material.LIME_STAINED_GLASS_PANE), new ItemStack(Material.COAL_BLOCK), null, new ItemStack(Material.COAL_BLOCK)},
|
||||
@ -1604,27 +1521,30 @@ public final class SlimefunSetup {
|
||||
new SlimefunItem(Categories.EASTER, (SlimefunItemStack) SlimefunItems.EASTER_EGG, RecipeType.ENHANCED_CRAFTING_TABLE,
|
||||
new ItemStack[] {null, null, null, new ItemStack(Material.LIME_DYE), new ItemStack(Material.EGG), new ItemStack(Material.PURPLE_DYE), null, null, null},
|
||||
new CustomItem(SlimefunItems.EASTER_EGG, 2))
|
||||
.register(true, new ItemInteractionHandler() {
|
||||
.register(true, new ItemUseHandler() {
|
||||
|
||||
private final List<ItemStack> gifts = Arrays.asList(
|
||||
new CustomItem(SlimefunItems.EASTER_CARROT_PIE, 4),
|
||||
new CustomItem(SlimefunItems.CARROT_JUICE, 1),
|
||||
new ItemStack(Material.EMERALD),
|
||||
new ItemStack(Material.CAKE),
|
||||
new ItemStack(Material.RABBIT_FOOT),
|
||||
new ItemStack(Material.GOLDEN_CARROT, 4)
|
||||
);
|
||||
|
||||
@Override
|
||||
public boolean onRightClick(ItemUseEvent e, Player p, ItemStack item) {
|
||||
if (SlimefunManager.isItemSimilar(item, SlimefunItems.EASTER_EGG, true)) {
|
||||
e.setCancelled(true);
|
||||
if (p.getGameMode() != GameMode.CREATIVE) ItemUtils.consumeItem(item, false);
|
||||
FireworkUtils.launchRandom(e.getPlayer(), 2);
|
||||
|
||||
List<ItemStack> gifts = new ArrayList<>();
|
||||
gifts.add(new CustomItem(SlimefunItems.EASTER_CARROT_PIE, 4));
|
||||
gifts.add(new CustomItem(SlimefunItems.CARROT_JUICE, 1));
|
||||
gifts.add(new ItemStack(Material.EMERALD));
|
||||
gifts.add(new ItemStack(Material.CAKE));
|
||||
gifts.add(new ItemStack(Material.RABBIT_FOOT));
|
||||
gifts.add(new ItemStack(Material.GOLDEN_CARROT, 4));
|
||||
|
||||
p.getWorld().dropItemNaturally(p.getLocation(), gifts.get(ThreadLocalRandom.current().nextInt(gifts.size())));
|
||||
return true;
|
||||
public void onRightClick(ItemUseEvent e) {
|
||||
e.cancel();
|
||||
|
||||
Player p = e.getPlayer();
|
||||
|
||||
if (p.getGameMode() != GameMode.CREATIVE) {
|
||||
ItemUtils.consumeItem(e.getItem(), false);
|
||||
}
|
||||
else return false;
|
||||
|
||||
FireworkUtils.launchRandom(p, 2);
|
||||
|
||||
p.getWorld().dropItemNaturally(p.getLocation(), gifts.get(ThreadLocalRandom.current().nextInt(gifts.size())));
|
||||
}
|
||||
});
|
||||
|
||||
@ -2156,7 +2076,7 @@ public final class SlimefunSetup {
|
||||
new ItemStack[] {SlimefunItems.BRASS_INGOT, new ItemStack(Material.ORANGE_STAINED_GLASS), SlimefunItems.BRASS_INGOT, SlimefunItems.POWER_CRYSTAL, SlimefunItems.TIN_DUST, SlimefunItems.POWER_CRYSTAL, SlimefunItems.BRASS_INGOT, new ItemStack(Material.ORANGE_STAINED_GLASS), SlimefunItems.BRASS_INGOT})
|
||||
.register(true);
|
||||
|
||||
new GPSTransmitter(Categories.GPS, SlimefunItems.GPS_TRANSMITTER, "GPS_TRANSMITTER", RecipeType.ENHANCED_CRAFTING_TABLE,
|
||||
new GPSTransmitter(Categories.GPS, (SlimefunItemStack) SlimefunItems.GPS_TRANSMITTER, RecipeType.ENHANCED_CRAFTING_TABLE,
|
||||
new ItemStack[] {null, null, SlimefunItems.ELECTRO_MAGNET, SlimefunItems.STEEL_INGOT, SlimefunItems.ADVANCED_CIRCUIT_BOARD, SlimefunItems.STEEL_INGOT, SlimefunItems.STEEL_INGOT, SlimefunItems.ELECTRIC_MOTOR, SlimefunItems.STEEL_INGOT}) {
|
||||
|
||||
@Override
|
||||
@ -2172,7 +2092,7 @@ public final class SlimefunSetup {
|
||||
}
|
||||
.registerChargeableBlock(true, 16);
|
||||
|
||||
new GPSTransmitter(Categories.GPS, SlimefunItems.GPS_TRANSMITTER_2, "GPS_TRANSMITTER_2", RecipeType.ENHANCED_CRAFTING_TABLE,
|
||||
new GPSTransmitter(Categories.GPS, (SlimefunItemStack) SlimefunItems.GPS_TRANSMITTER_2, RecipeType.ENHANCED_CRAFTING_TABLE,
|
||||
new ItemStack[] {SlimefunItems.GPS_TRANSMITTER, SlimefunItems.BRONZE_INGOT, SlimefunItems.GPS_TRANSMITTER, SlimefunItems.BRONZE_INGOT, SlimefunItems.CARBON, SlimefunItems.BRONZE_INGOT, SlimefunItems.GPS_TRANSMITTER, SlimefunItems.BRONZE_INGOT, SlimefunItems.GPS_TRANSMITTER}) {
|
||||
|
||||
@Override
|
||||
@ -2187,7 +2107,7 @@ public final class SlimefunSetup {
|
||||
|
||||
}.registerChargeableBlock(true, 64);
|
||||
|
||||
new GPSTransmitter(Categories.GPS, SlimefunItems.GPS_TRANSMITTER_3, "GPS_TRANSMITTER_3", RecipeType.ENHANCED_CRAFTING_TABLE,
|
||||
new GPSTransmitter(Categories.GPS, (SlimefunItemStack) SlimefunItems.GPS_TRANSMITTER_3, RecipeType.ENHANCED_CRAFTING_TABLE,
|
||||
new ItemStack[] {SlimefunItems.GPS_TRANSMITTER_2, SlimefunItems.CORINTHIAN_BRONZE_INGOT, SlimefunItems.GPS_TRANSMITTER_2, SlimefunItems.CORINTHIAN_BRONZE_INGOT, SlimefunItems.CARBONADO, SlimefunItems.CORINTHIAN_BRONZE_INGOT, SlimefunItems.GPS_TRANSMITTER_2, SlimefunItems.CORINTHIAN_BRONZE_INGOT, SlimefunItems.GPS_TRANSMITTER_2}) {
|
||||
|
||||
@Override
|
||||
@ -2202,7 +2122,7 @@ public final class SlimefunSetup {
|
||||
|
||||
}.registerChargeableBlock(true, 256);
|
||||
|
||||
new GPSTransmitter(Categories.GPS, SlimefunItems.GPS_TRANSMITTER_4, "GPS_TRANSMITTER_4", RecipeType.ENHANCED_CRAFTING_TABLE,
|
||||
new GPSTransmitter(Categories.GPS, (SlimefunItemStack) SlimefunItems.GPS_TRANSMITTER_4, RecipeType.ENHANCED_CRAFTING_TABLE,
|
||||
new ItemStack[] {SlimefunItems.GPS_TRANSMITTER_3, SlimefunItems.BLISTERING_INGOT_3, SlimefunItems.GPS_TRANSMITTER_3, SlimefunItems.NICKEL_INGOT, SlimefunItems.CARBONADO, SlimefunItems.NICKEL_INGOT, SlimefunItems.GPS_TRANSMITTER_3, SlimefunItems.BLISTERING_INGOT_3, SlimefunItems.GPS_TRANSMITTER_3}) {
|
||||
|
||||
@Override
|
||||
@ -2217,27 +2137,15 @@ public final class SlimefunSetup {
|
||||
|
||||
}.registerChargeableBlock(true, 1024);
|
||||
|
||||
new SlimefunItem(Categories.GPS, SlimefunItems.GPS_CONTROL_PANEL, "GPS_CONTROL_PANEL", RecipeType.ENHANCED_CRAFTING_TABLE,
|
||||
new GPSControlPanel(Categories.GPS, (SlimefunItemStack) SlimefunItems.GPS_CONTROL_PANEL, RecipeType.ENHANCED_CRAFTING_TABLE,
|
||||
new ItemStack[] {null, null, SlimefunItems.ELECTRO_MAGNET, SlimefunItems.COBALT_INGOT, SlimefunItems.ADVANCED_CIRCUIT_BOARD, SlimefunItems.COBALT_INGOT, SlimefunItems.ALUMINUM_BRASS_INGOT, SlimefunItems.ALUMINUM_BRASS_INGOT, SlimefunItems.ALUMINUM_BRASS_INGOT})
|
||||
.register(true, new ItemInteractionHandler() {
|
||||
.register(true);
|
||||
|
||||
@Override
|
||||
public boolean onRightClick(ItemUseEvent e, Player p, ItemStack stack) {
|
||||
if (e.getClickedBlock() == null) return false;
|
||||
String item = BlockStorage.checkID(e.getClickedBlock());
|
||||
if (item == null || !item.equals("GPS_CONTROL_PANEL")) return false;
|
||||
e.setCancelled(true);
|
||||
|
||||
Slimefun.getGPSNetwork().openTransmitterControlPanel(p);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
new SlimefunItem(Categories.GPS, SlimefunItems.GPS_MARKER_TOOL, "GPS_MARKER_TOOL", RecipeType.ENHANCED_CRAFTING_TABLE,
|
||||
new SlimefunItem(Categories.GPS, (SlimefunItemStack) SlimefunItems.GPS_MARKER_TOOL, RecipeType.ENHANCED_CRAFTING_TABLE,
|
||||
new ItemStack[] {null, SlimefunItems.ELECTRO_MAGNET, null, new ItemStack(Material.LAPIS_LAZULI), SlimefunItems.BASIC_CIRCUIT_BOARD, new ItemStack(Material.LAPIS_LAZULI), new ItemStack(Material.REDSTONE), SlimefunItems.REDSTONE_ALLOY, new ItemStack(Material.REDSTONE)})
|
||||
.register(true);
|
||||
|
||||
new SlimefunItem(Categories.GPS, SlimefunItems.GPS_EMERGENCY_TRANSMITTER, "GPS_EMERGENCY_TRANSMITTER", RecipeType.ENHANCED_CRAFTING_TABLE,
|
||||
new SlimefunItem(Categories.GPS, (SlimefunItemStack) SlimefunItems.GPS_EMERGENCY_TRANSMITTER, RecipeType.ENHANCED_CRAFTING_TABLE,
|
||||
new ItemStack[] {null, SlimefunItems.ELECTRO_MAGNET, null, null, SlimefunItems.GPS_TRANSMITTER, null, null, SlimefunItems.ESSENCE_OF_AFTERLIFE, null})
|
||||
.register(true);
|
||||
|
||||
@ -3080,26 +2988,10 @@ public final class SlimefunSetup {
|
||||
new ItemStack[] {null, SlimefunItems.HOLOGRAM_PROJECTOR, null, SlimefunItems.REINFORCED_PLATE, SlimefunItems.CARGO_MOTOR, SlimefunItems.REINFORCED_PLATE, SlimefunItems.ALUMINUM_BRONZE_INGOT, SlimefunItems.ANDROID_MEMORY_CORE, SlimefunItems.ALUMINUM_BRONZE_INGOT})
|
||||
.register(true);
|
||||
|
||||
new SlimefunItem(Categories.CARGO, (SlimefunItemStack) SlimefunItems.CARGO_NODE, RecipeType.ENHANCED_CRAFTING_TABLE,
|
||||
new CargoConnector(Categories.CARGO, (SlimefunItemStack) SlimefunItems.CARGO_NODE, RecipeType.ENHANCED_CRAFTING_TABLE,
|
||||
new ItemStack[] {SlimefunItems.BRONZE_INGOT, SlimefunItems.SILVER_INGOT, SlimefunItems.BRONZE_INGOT, SlimefunItems.SILVER_INGOT, SlimefunItems.CARGO_MOTOR, SlimefunItems.SILVER_INGOT, SlimefunItems.BRONZE_INGOT, SlimefunItems.SILVER_INGOT, SlimefunItems.BRONZE_INGOT},
|
||||
new CustomItem(SlimefunItems.CARGO_NODE, 4))
|
||||
.register(true, new ItemInteractionHandler() {
|
||||
|
||||
@Override
|
||||
public boolean onRightClick(ItemUseEvent e, Player p, ItemStack stack) {
|
||||
if (e.getClickedBlock() == null) return false;
|
||||
String id = BlockStorage.checkID(e.getClickedBlock());
|
||||
if (id == null || !id.equals("CARGO_NODE")) return false;
|
||||
|
||||
if (CargoNet.getNetworkFromLocation(e.getClickedBlock().getLocation()) != null) {
|
||||
p.sendMessage(ChatColors.color("&7Connected: " + "&2\u2714"));
|
||||
}
|
||||
else {
|
||||
p.sendMessage(ChatColors.color("&7Connected: " + "&4\u2718"));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
.register(true);
|
||||
|
||||
new CargoInputNode(Categories.CARGO, SlimefunItems.CARGO_INPUT, "CARGO_NODE_INPUT", RecipeType.ENHANCED_CRAFTING_TABLE,
|
||||
new ItemStack[] {null, new ItemStack(Material.HOPPER), null, SlimefunItems.BILLON_INGOT, SlimefunItems.CARGO_NODE, SlimefunItems.BILLON_INGOT, null, new ItemStack(Material.HOPPER), null},
|
||||
|
@ -245,7 +245,7 @@ public final class SlimefunPlugin extends JavaPlugin {
|
||||
if (config.getBoolean("items.soulbound")) new SoulboundListener(this);
|
||||
|
||||
// Handle Slimefun Guide being given on Join
|
||||
if (config.getBoolean("options.give-guide-on-first-join")) new SlimefunGuideListener(this);
|
||||
new SlimefunGuideListener(this, config.getBoolean("options.give-guide-on-first-join"));
|
||||
|
||||
// Load/Unload Worlds in Slimefun
|
||||
new WorldListener(this);
|
||||
|
@ -48,6 +48,7 @@ messages:
|
||||
mode-change: '&b%device% mode changed to: &9%mode%'
|
||||
disabled-in-world: '&4&lThis Item has been disabled in this world'
|
||||
disabled-item: '&4&lThis Item has been disabled! How did you even get that?'
|
||||
no-tome-yourself: '&cYou cannot use the &4Tome of Knowledge &con yourself...'
|
||||
|
||||
talisman:
|
||||
anvil: '&a&oYour Talisman saved your tool from breaking'
|
||||
|
Loading…
Reference in New Issue
Block a user