mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
Fix issue #966 (Trying again)
This commit is contained in:
parent
4d326f5228
commit
640915d85a
@ -1,200 +1,211 @@
|
|||||||
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines;
|
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.Damageable;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.compatibility.MaterialHelper;
|
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.general.World.CustomSkull;
|
import me.mrCookieSlime.CSCoreLibPlugin.compatibility.MaterialHelper;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
|
import me.mrCookieSlime.CSCoreLibPlugin.general.World.CustomSkull;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler;
|
import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.UnregisterReason;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler;
|
||||||
import me.mrCookieSlime.Slimefun.Setup.Messages;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.UnregisterReason;
|
||||||
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
|
import me.mrCookieSlime.Slimefun.Setup.Messages;
|
||||||
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
|
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||||
import me.mrCookieSlime.Slimefun.api.item_transport.CargoNet;
|
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
|
||||||
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
|
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
|
||||||
|
import me.mrCookieSlime.Slimefun.api.item_transport.CargoNet;
|
||||||
public class AdvancedCargoOutputNode extends SlimefunItem {
|
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
|
||||||
|
|
||||||
private static final int[] border = {0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 17, 18, 22, 23, 24, 26, 27, 31, 32, 33, 34, 35, 36, 40, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53};
|
public class AdvancedCargoOutputNode extends SlimefunItem {
|
||||||
|
|
||||||
public AdvancedCargoOutputNode(Category category, ItemStack item, String name, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) {
|
private static final int[] border = {0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 17, 18, 22, 23, 24, 26, 27, 31, 32, 33, 34, 35, 36, 40, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53};
|
||||||
super(category, item, name, recipeType, recipe, recipeOutput);
|
|
||||||
|
public AdvancedCargoOutputNode(Category category, ItemStack item, String name, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) {
|
||||||
new BlockMenuPreset(name, "&cOutput Node") {
|
super(category, item, name, recipeType, recipe, recipeOutput);
|
||||||
|
|
||||||
@Override
|
new BlockMenuPreset(name, "&cOutput Node") {
|
||||||
public void init() {
|
|
||||||
constructMenu(this);
|
@Override
|
||||||
}
|
public void init() {
|
||||||
|
constructMenu(this);
|
||||||
@Override
|
}
|
||||||
public void newInstance(final BlockMenu menu, final Block b) {
|
|
||||||
try {
|
@Override
|
||||||
if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "filter-type") == null || BlockStorage.getLocationInfo(b.getLocation(), "filter-type").equals("whitelist")) {
|
public void newInstance(final BlockMenu menu, final Block b) {
|
||||||
menu.replaceExistingItem(15, new CustomItem(new ItemStack(Material.WHITE_WOOL), "&7Type: &rWhitelist", "", "&e> Click to change it to Blacklist"));
|
try {
|
||||||
menu.addMenuClickHandler(15, (p, slot, item, action) -> {
|
if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "filter-type") == null || BlockStorage.getLocationInfo(b.getLocation(), "filter-type").equals("whitelist")) {
|
||||||
BlockStorage.addBlockInfo(b, "filter-type", "blacklist");
|
menu.replaceExistingItem(15, new CustomItem(new ItemStack(Material.WHITE_WOOL), "&7Type: &rWhitelist", "", "&e> Click to change it to Blacklist"));
|
||||||
newInstance(menu, b);
|
menu.addMenuClickHandler(15, (p, slot, item, action) -> {
|
||||||
return false;
|
BlockStorage.addBlockInfo(b, "filter-type", "blacklist");
|
||||||
});
|
newInstance(menu, b);
|
||||||
}
|
return false;
|
||||||
else {
|
});
|
||||||
menu.replaceExistingItem(15, new CustomItem(new ItemStack(Material.BLACK_WOOL), "&7Type: &8Blacklist", "", "&e> Click to change it to Whitelist"));
|
}
|
||||||
menu.addMenuClickHandler(15, (p, slot, item, action) -> {
|
else {
|
||||||
BlockStorage.addBlockInfo(b, "filter-type", "whitelist");
|
menu.replaceExistingItem(15, new CustomItem(new ItemStack(Material.BLACK_WOOL), "&7Type: &8Blacklist", "", "&e> Click to change it to Whitelist"));
|
||||||
newInstance(menu, b);
|
menu.addMenuClickHandler(15, (p, slot, item, action) -> {
|
||||||
return false;
|
BlockStorage.addBlockInfo(b, "filter-type", "whitelist");
|
||||||
});
|
newInstance(menu, b);
|
||||||
}
|
return false;
|
||||||
|
});
|
||||||
if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "filter-durability") == null || BlockStorage.getLocationInfo(b.getLocation(), "filter-durability").equals("false")) {
|
}
|
||||||
menu.replaceExistingItem(16, new CustomItem(new ItemStack(Material.STONE_SWORD, (byte) 20), "&7Include Sub-IDs/Durability: &4\u2718", "", "&e> Click to toggle whether the Durability has to match"));
|
|
||||||
menu.addMenuClickHandler(16, (p, slot, item, action) -> {
|
if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "filter-durability") == null || BlockStorage.getLocationInfo(b.getLocation(), "filter-durability").equals("false")) {
|
||||||
BlockStorage.addBlockInfo(b, "filter-durability", "true");
|
ItemStack is = new ItemStack(Material.STONE_SWORD);
|
||||||
newInstance(menu, b);
|
Damageable dmg = (Damageable) is.getItemMeta();
|
||||||
return false;
|
dmg.setDamage(20);
|
||||||
});
|
is.setItemMeta((ItemMeta) dmg);
|
||||||
}
|
|
||||||
else {
|
menu.replaceExistingItem(16, new CustomItem(is, "&7Include Sub-IDs/Durability: &4\u2718", "", "&e> Click to toggle whether the Durability has to match"));
|
||||||
menu.replaceExistingItem(16, new CustomItem(new ItemStack(Material.GOLDEN_SWORD, (byte) 20), "&7Include Sub-IDs/Durability: &2\u2714", "", "&e> Click to toggle whether the Durability has to match"));
|
menu.addMenuClickHandler(16, (p, slot, item, action) -> {
|
||||||
menu.addMenuClickHandler(16, (p, slot, item, action) -> {
|
BlockStorage.addBlockInfo(b, "filter-durability", "true");
|
||||||
BlockStorage.addBlockInfo(b, "filter-durability", "false");
|
newInstance(menu, b);
|
||||||
newInstance(menu, b);
|
return false;
|
||||||
return false;
|
});
|
||||||
});
|
}
|
||||||
}
|
else {
|
||||||
|
ItemStack is = new ItemStack(Material.GOLDEN_SWORD);
|
||||||
if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "filter-lore") == null || BlockStorage.getLocationInfo(b.getLocation(), "filter-lore").equals("true")) {
|
Damageable dmg = (Damageable) is.getItemMeta();
|
||||||
menu.replaceExistingItem(25, new CustomItem(new ItemStack(Material.MAP), "&7Include Lore: &2\u2714", "", "&e> Click to toggle whether the Lore has to match"));
|
dmg.setDamage(20);
|
||||||
menu.addMenuClickHandler(25, (p, slot, item, action) -> {
|
is.setItemMeta((ItemMeta) dmg);
|
||||||
BlockStorage.addBlockInfo(b, "filter-lore", "false");
|
menu.replaceExistingItem(16, new CustomItem(is, "&7Include Sub-IDs/Durability: &2\u2714", "", "&e> Click to toggle whether the Durability has to match"));
|
||||||
newInstance(menu, b);
|
menu.addMenuClickHandler(16, (p, slot, item, action) -> {
|
||||||
return false;
|
BlockStorage.addBlockInfo(b, "filter-durability", "false");
|
||||||
});
|
newInstance(menu, b);
|
||||||
}
|
return false;
|
||||||
else {
|
});
|
||||||
menu.replaceExistingItem(25, new CustomItem(new ItemStack(Material.MAP), "&7Include Lore: &4\u2718", "", "&e> Click to toggle whether the Lore has to match"));
|
}
|
||||||
menu.addMenuClickHandler(25, (p, slot, item, action) -> {
|
|
||||||
BlockStorage.addBlockInfo(b, "filter-lore", "true");
|
if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "filter-lore") == null || BlockStorage.getLocationInfo(b.getLocation(), "filter-lore").equals("true")) {
|
||||||
newInstance(menu, b);
|
menu.replaceExistingItem(25, new CustomItem(new ItemStack(Material.MAP), "&7Include Lore: &2\u2714", "", "&e> Click to toggle whether the Lore has to match"));
|
||||||
return false;
|
menu.addMenuClickHandler(25, (p, slot, item, action) -> {
|
||||||
});
|
BlockStorage.addBlockInfo(b, "filter-lore", "false");
|
||||||
}
|
newInstance(menu, b);
|
||||||
|
return false;
|
||||||
menu.replaceExistingItem(41, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjI1OTliZDk4NjY1OWI4Y2UyYzQ5ODg1MjVjOTRlMTlkZGQzOWZhZDA4YTM4Mjg0YTE5N2YxYjcwNjc1YWNjIn19fQ=="), "&bChannel", "", "&e> Click to decrease the Channel ID by 1"));
|
});
|
||||||
menu.addMenuClickHandler(41, (p, slot, item, action) -> {
|
}
|
||||||
int channel = Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "frequency")) - 1;
|
else {
|
||||||
if (channel < 0) {
|
menu.replaceExistingItem(25, new CustomItem(new ItemStack(Material.MAP), "&7Include Lore: &4\u2718", "", "&e> Click to toggle whether the Lore has to match"));
|
||||||
if (CargoNet.EXTRA_CHANNELS) channel = 16;
|
menu.addMenuClickHandler(25, (p, slot, item, action) -> {
|
||||||
else channel = 15;
|
BlockStorage.addBlockInfo(b, "filter-lore", "true");
|
||||||
}
|
newInstance(menu, b);
|
||||||
BlockStorage.addBlockInfo(b, "frequency", String.valueOf(channel));
|
return false;
|
||||||
newInstance(menu, b);
|
});
|
||||||
return false;
|
}
|
||||||
});
|
|
||||||
|
menu.replaceExistingItem(41, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjI1OTliZDk4NjY1OWI4Y2UyYzQ5ODg1MjVjOTRlMTlkZGQzOWZhZDA4YTM4Mjg0YTE5N2YxYjcwNjc1YWNjIn19fQ=="), "&bChannel", "", "&e> Click to decrease the Channel ID by 1"));
|
||||||
int channel = ((!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "frequency") == null) ? 0: (Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "frequency"))));
|
menu.addMenuClickHandler(41, (p, slot, item, action) -> {
|
||||||
|
int channel = Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "frequency")) - 1;
|
||||||
if (channel == 16) {
|
if (channel < 0) {
|
||||||
menu.replaceExistingItem(42, new CustomItem(SlimefunItems.CHEST_TERMINAL, "&bChannel ID: &3" + (channel + 1)));
|
if (CargoNet.EXTRA_CHANNELS) channel = 16;
|
||||||
menu.addMenuClickHandler(42,
|
else channel = 15;
|
||||||
(p, slot, item, action) -> false
|
}
|
||||||
);
|
BlockStorage.addBlockInfo(b, "frequency", String.valueOf(channel));
|
||||||
}
|
newInstance(menu, b);
|
||||||
else {
|
return false;
|
||||||
menu.replaceExistingItem(42, new CustomItem(new ItemStack(MaterialHelper.WoolColours[channel]), "&bChannel ID: &3" + (channel + 1)));
|
});
|
||||||
menu.addMenuClickHandler(42,
|
|
||||||
(p, slot, item, action) -> false
|
int channel = ((!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "frequency") == null) ? 0: (Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "frequency"))));
|
||||||
);
|
|
||||||
}
|
if (channel == 16) {
|
||||||
|
menu.replaceExistingItem(42, new CustomItem(SlimefunItems.CHEST_TERMINAL, "&bChannel ID: &3" + (channel + 1)));
|
||||||
menu.replaceExistingItem(43, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzJmOTEwYzQ3ZGEwNDJlNGFhMjhhZjZjYzgxY2Y0OGFjNmNhZjM3ZGFiMzVmODhkYjk5M2FjY2I5ZGZlNTE2In19fQ=="), "&bChannel", "", "&e> Click to increase the Channel ID by 1"));
|
menu.addMenuClickHandler(42,
|
||||||
menu.addMenuClickHandler(43, (p, slot, item, action) -> {
|
(p, slot, item, action) -> false
|
||||||
int channeln = Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "frequency")) + 1;
|
);
|
||||||
|
}
|
||||||
if (CargoNet.EXTRA_CHANNELS) {
|
else {
|
||||||
if (channeln > 16) channeln = 0;
|
menu.replaceExistingItem(42, new CustomItem(new ItemStack(MaterialHelper.WoolColours[channel]), "&bChannel ID: &3" + (channel + 1)));
|
||||||
}
|
menu.addMenuClickHandler(42,
|
||||||
else {
|
(p, slot, item, action) -> false
|
||||||
if (channeln > 15) channeln = 0;
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockStorage.addBlockInfo(b, "frequency", String.valueOf(channeln));
|
menu.replaceExistingItem(43, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzJmOTEwYzQ3ZGEwNDJlNGFhMjhhZjZjYzgxY2Y0OGFjNmNhZjM3ZGFiMzVmODhkYjk5M2FjY2I5ZGZlNTE2In19fQ=="), "&bChannel", "", "&e> Click to increase the Channel ID by 1"));
|
||||||
newInstance(menu, b);
|
menu.addMenuClickHandler(43, (p, slot, item, action) -> {
|
||||||
return false;
|
int channeln = Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "frequency")) + 1;
|
||||||
});
|
|
||||||
|
if (CargoNet.EXTRA_CHANNELS) {
|
||||||
} catch (Exception e) {
|
if (channeln > 16) channeln = 0;
|
||||||
e.printStackTrace();
|
}
|
||||||
}
|
else {
|
||||||
}
|
if (channeln > 15) channeln = 0;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public boolean canOpen(Block b, Player p) {
|
BlockStorage.addBlockInfo(b, "frequency", String.valueOf(channeln));
|
||||||
boolean open = CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b) || p.hasPermission("slimefun.cargo.bypass");
|
newInstance(menu, b);
|
||||||
if (!open) {
|
return false;
|
||||||
Messages.local.sendTranslation(p, "inventory.no-access", true);
|
});
|
||||||
}
|
|
||||||
return open;
|
} catch (Exception e) {
|
||||||
}
|
e.printStackTrace();
|
||||||
|
}
|
||||||
@Override
|
}
|
||||||
public int[] getSlotsAccessedByItemTransport(ItemTransportFlow flow) {
|
|
||||||
return new int[0];
|
@Override
|
||||||
}
|
public boolean canOpen(Block b, Player p) {
|
||||||
};
|
boolean open = CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b) || p.hasPermission("slimefun.cargo.bypass");
|
||||||
|
if (!open) {
|
||||||
registerBlockHandler(name, new SlimefunBlockHandler() {
|
Messages.local.sendTranslation(p, "inventory.no-access", true);
|
||||||
|
}
|
||||||
@Override
|
return open;
|
||||||
public void onPlace(Player p, Block b, SlimefunItem item) {
|
}
|
||||||
BlockStorage.addBlockInfo(b, "owner", p.getUniqueId().toString());
|
|
||||||
BlockStorage.addBlockInfo(b, "index", "0");
|
@Override
|
||||||
BlockStorage.addBlockInfo(b, "frequency", "0");
|
public int[] getSlotsAccessedByItemTransport(ItemTransportFlow flow) {
|
||||||
BlockStorage.addBlockInfo(b, "filter-type", "whitelist");
|
return new int[0];
|
||||||
BlockStorage.addBlockInfo(b, "filter-lore", "true");
|
}
|
||||||
BlockStorage.addBlockInfo(b, "filter-durability", "false");
|
};
|
||||||
}
|
|
||||||
|
registerBlockHandler(name, new SlimefunBlockHandler() {
|
||||||
@Override
|
|
||||||
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
|
@Override
|
||||||
BlockMenu inv = BlockStorage.getInventory(b);
|
public void onPlace(Player p, Block b, SlimefunItem item) {
|
||||||
if (inv != null) {
|
BlockStorage.addBlockInfo(b, "owner", p.getUniqueId().toString());
|
||||||
for (int slot: getInputSlots()) {
|
BlockStorage.addBlockInfo(b, "index", "0");
|
||||||
if (inv.getItemInSlot(slot) != null) {
|
BlockStorage.addBlockInfo(b, "frequency", "0");
|
||||||
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
|
BlockStorage.addBlockInfo(b, "filter-type", "whitelist");
|
||||||
inv.replaceExistingItem(slot, null);
|
BlockStorage.addBlockInfo(b, "filter-lore", "true");
|
||||||
}
|
BlockStorage.addBlockInfo(b, "filter-durability", "false");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return true;
|
@Override
|
||||||
}
|
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
|
||||||
});
|
BlockMenu inv = BlockStorage.getInventory(b);
|
||||||
}
|
if (inv != null) {
|
||||||
|
for (int slot: getInputSlots()) {
|
||||||
protected void constructMenu(BlockMenuPreset preset) {
|
if (inv.getItemInSlot(slot) != null) {
|
||||||
for (int i : border) {
|
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
|
||||||
preset.addItem(i, new CustomItem(new ItemStack(Material.CYAN_STAINED_GLASS_PANE), " "),
|
inv.replaceExistingItem(slot, null);
|
||||||
(p, slot, item, action) -> false
|
}
|
||||||
);
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
preset.addItem(2, new CustomItem(new ItemStack(Material.PAPER), "&3Items", "", "&bPut in all Items you want to", "&bblacklist/whitelist"),
|
}
|
||||||
(p, slot, item, action) -> false
|
});
|
||||||
);
|
}
|
||||||
}
|
|
||||||
|
protected void constructMenu(BlockMenuPreset preset) {
|
||||||
public int[] getInputSlots() {
|
for (int i : border) {
|
||||||
return new int[] {19, 20, 21, 28, 29, 30, 37, 38, 39};
|
preset.addItem(i, new CustomItem(new ItemStack(Material.CYAN_STAINED_GLASS_PANE), " "),
|
||||||
}
|
(p, slot, item, action) -> false
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
preset.addItem(2, new CustomItem(new ItemStack(Material.PAPER), "&3Items", "", "&bPut in all Items you want to", "&bblacklist/whitelist"),
|
||||||
|
(p, slot, item, action) -> false
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int[] getInputSlots() {
|
||||||
|
return new int[] {19, 20, 21, 28, 29, 30, 37, 38, 39};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -1,218 +1,228 @@
|
|||||||
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines;
|
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines;
|
||||||
|
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.compatibility.MaterialHelper;
|
import me.mrCookieSlime.CSCoreLibPlugin.compatibility.MaterialHelper;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.Damageable;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.general.World.CustomSkull;
|
import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
|
import me.mrCookieSlime.CSCoreLibPlugin.general.World.CustomSkull;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler;
|
import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.UnregisterReason;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler;
|
||||||
import me.mrCookieSlime.Slimefun.Setup.Messages;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.UnregisterReason;
|
||||||
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
|
import me.mrCookieSlime.Slimefun.Setup.Messages;
|
||||||
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
|
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||||
import me.mrCookieSlime.Slimefun.api.item_transport.CargoNet;
|
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
|
||||||
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
|
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
|
||||||
|
import me.mrCookieSlime.Slimefun.api.item_transport.CargoNet;
|
||||||
public class CargoInputNode extends SlimefunItem {
|
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
|
||||||
|
|
||||||
private static final int[] border = {0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 17, 18, 22, 23, 26, 27, 31, 32, 33, 34, 35, 36, 40, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53};
|
public class CargoInputNode extends SlimefunItem {
|
||||||
|
|
||||||
public CargoInputNode(Category category, ItemStack item, String name, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) {
|
private static final int[] border = {0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 17, 18, 22, 23, 26, 27, 31, 32, 33, 34, 35, 36, 40, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53};
|
||||||
super(category, item, name, recipeType, recipe, recipeOutput);
|
|
||||||
|
public CargoInputNode(Category category, ItemStack item, String name, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) {
|
||||||
new BlockMenuPreset(name, "&3Input Node") {
|
super(category, item, name, recipeType, recipe, recipeOutput);
|
||||||
|
|
||||||
@Override
|
new BlockMenuPreset(name, "&3Input Node") {
|
||||||
public void init() {
|
|
||||||
constructMenu(this);
|
@Override
|
||||||
}
|
public void init() {
|
||||||
|
constructMenu(this);
|
||||||
@Override
|
}
|
||||||
public void newInstance(final BlockMenu menu, final Block b) {
|
|
||||||
try {
|
@Override
|
||||||
if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "filter-type") == null || BlockStorage.getLocationInfo(b.getLocation(), "filter-type").equals("whitelist")) {
|
public void newInstance(final BlockMenu menu, final Block b) {
|
||||||
menu.replaceExistingItem(15, new CustomItem(new ItemStack(Material.WHITE_WOOL), "&7Type: &rWhitelist", "", "&e> Click to change it to Blacklist"));
|
try {
|
||||||
menu.addMenuClickHandler(15, (p, slot, item, action) -> {
|
if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "filter-type") == null || BlockStorage.getLocationInfo(b.getLocation(), "filter-type").equals("whitelist")) {
|
||||||
BlockStorage.addBlockInfo(b, "filter-type", "blacklist");
|
menu.replaceExistingItem(15, new CustomItem(new ItemStack(Material.WHITE_WOOL), "&7Type: &rWhitelist", "", "&e> Click to change it to Blacklist"));
|
||||||
newInstance(menu, b);
|
menu.addMenuClickHandler(15, (p, slot, item, action) -> {
|
||||||
return false;
|
BlockStorage.addBlockInfo(b, "filter-type", "blacklist");
|
||||||
});
|
newInstance(menu, b);
|
||||||
}
|
return false;
|
||||||
else {
|
});
|
||||||
menu.replaceExistingItem(15, new CustomItem(new ItemStack(Material.BLACK_WOOL), "&7Type: &8Blacklist", "", "&e> Click to change it to Whitelist"));
|
}
|
||||||
menu.addMenuClickHandler(15, (p, slot, item, action) -> {
|
else {
|
||||||
BlockStorage.addBlockInfo(b, "filter-type", "whitelist");
|
menu.replaceExistingItem(15, new CustomItem(new ItemStack(Material.BLACK_WOOL), "&7Type: &8Blacklist", "", "&e> Click to change it to Whitelist"));
|
||||||
newInstance(menu, b);
|
menu.addMenuClickHandler(15, (p, slot, item, action) -> {
|
||||||
return false;
|
BlockStorage.addBlockInfo(b, "filter-type", "whitelist");
|
||||||
});
|
newInstance(menu, b);
|
||||||
}
|
return false;
|
||||||
|
});
|
||||||
if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "filter-durability") == null || BlockStorage.getLocationInfo(b.getLocation(), "filter-durability").equals("false")) {
|
}
|
||||||
menu.replaceExistingItem(16, new CustomItem(new ItemStack(Material.STONE_SWORD, (byte) 20), "&7Include Sub-IDs/Durability: &4\u2718", "", "&e> Click to toggle whether the Durability has to match"));
|
|
||||||
menu.addMenuClickHandler(16, (p, slot, item, action) -> {
|
if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "filter-durability") == null || BlockStorage.getLocationInfo(b.getLocation(), "filter-durability").equals("false")) {
|
||||||
BlockStorage.addBlockInfo(b, "filter-durability", "true");
|
ItemStack is = new ItemStack(Material.STONE_SWORD);
|
||||||
newInstance(menu, b);
|
Damageable dmg = (Damageable) is.getItemMeta();
|
||||||
return false;
|
dmg.setDamage(20);
|
||||||
});
|
is.setItemMeta((ItemMeta) dmg);
|
||||||
}
|
menu.replaceExistingItem(16, new CustomItem(is, "&7Include Sub-IDs/Durability: &4\u2718", "", "&e> Click to toggle whether the Durability has to match"));
|
||||||
else {
|
menu.addMenuClickHandler(16, (p, slot, item, action) -> {
|
||||||
menu.replaceExistingItem(16, new CustomItem(new ItemStack(Material.GOLDEN_SWORD, (byte) 20), "&7Include Sub-IDs/Durability: &2\u2714", "", "&e> Click to toggle whether the Durability has to match"));
|
BlockStorage.addBlockInfo(b, "filter-durability", "true");
|
||||||
menu.addMenuClickHandler(16, (p, slot, item, action) -> {
|
newInstance(menu, b);
|
||||||
BlockStorage.addBlockInfo(b, "filter-durability", "false");
|
return false;
|
||||||
newInstance(menu, b);
|
});
|
||||||
return false;
|
}
|
||||||
});
|
else {
|
||||||
}
|
ItemStack is = new ItemStack(Material.GOLDEN_SWORD);
|
||||||
|
Damageable dmg = (Damageable) is.getItemMeta();
|
||||||
if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "round-robin") == null || BlockStorage.getLocationInfo(b.getLocation(), "round-robin").equals("false")) {
|
dmg.setDamage(20);
|
||||||
menu.replaceExistingItem(24, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDc4ZjJiN2U1ZTc1NjM5ZWE3ZmI3OTZjMzVkMzY0YzRkZjI4YjQyNDNlNjZiNzYyNzdhYWRjZDYyNjEzMzcifX19"), "&7Round-Robin Mode: &4\u2718", "", "&e> Click to enable Round Robin Mode", "&e(Items will be equally distributed on the Channel)"));
|
is.setItemMeta((ItemMeta) dmg);
|
||||||
menu.addMenuClickHandler(24, (p, slot, item, action) -> {
|
menu.replaceExistingItem(16, new CustomItem(is, "&7Include Sub-IDs/Durability: &2\u2714", "", "&e> Click to toggle whether the Durability has to match"));
|
||||||
BlockStorage.addBlockInfo(b, "round-robin", "true");
|
menu.addMenuClickHandler(16, (p, slot, item, action) -> {
|
||||||
newInstance(menu, b);
|
BlockStorage.addBlockInfo(b, "filter-durability", "false");
|
||||||
return false;
|
newInstance(menu, b);
|
||||||
});
|
return false;
|
||||||
}
|
});
|
||||||
else {
|
}
|
||||||
menu.replaceExistingItem(24, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDc4ZjJiN2U1ZTc1NjM5ZWE3ZmI3OTZjMzVkMzY0YzRkZjI4YjQyNDNlNjZiNzYyNzdhYWRjZDYyNjEzMzcifX19"), "&7Round-Robin Mode: &2\u2714", "", "&e> Click to disable Round Robin Mode", "&e(Items will be equally distributed on the Channel)"));
|
|
||||||
menu.addMenuClickHandler(24, (p, slot, item, action) -> {
|
if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "round-robin") == null || BlockStorage.getLocationInfo(b.getLocation(), "round-robin").equals("false")) {
|
||||||
BlockStorage.addBlockInfo(b, "round-robin", "false");
|
menu.replaceExistingItem(24, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDc4ZjJiN2U1ZTc1NjM5ZWE3ZmI3OTZjMzVkMzY0YzRkZjI4YjQyNDNlNjZiNzYyNzdhYWRjZDYyNjEzMzcifX19"), "&7Round-Robin Mode: &4\u2718", "", "&e> Click to enable Round Robin Mode", "&e(Items will be equally distributed on the Channel)"));
|
||||||
newInstance(menu, b);
|
menu.addMenuClickHandler(24, (p, slot, item, action) -> {
|
||||||
return false;
|
BlockStorage.addBlockInfo(b, "round-robin", "true");
|
||||||
});
|
newInstance(menu, b);
|
||||||
}
|
return false;
|
||||||
|
});
|
||||||
if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "filter-lore") == null || BlockStorage.getLocationInfo(b.getLocation(), "filter-lore").equals("true")) {
|
}
|
||||||
menu.replaceExistingItem(25, new CustomItem(new ItemStack(Material.MAP), "&7Include Lore: &2\u2714", "", "&e> Click to toggle whether the Lore has to match"));
|
else {
|
||||||
menu.addMenuClickHandler(25, (p, slot, item, action) -> {
|
menu.replaceExistingItem(24, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDc4ZjJiN2U1ZTc1NjM5ZWE3ZmI3OTZjMzVkMzY0YzRkZjI4YjQyNDNlNjZiNzYyNzdhYWRjZDYyNjEzMzcifX19"), "&7Round-Robin Mode: &2\u2714", "", "&e> Click to disable Round Robin Mode", "&e(Items will be equally distributed on the Channel)"));
|
||||||
BlockStorage.addBlockInfo(b, "filter-lore", "false");
|
menu.addMenuClickHandler(24, (p, slot, item, action) -> {
|
||||||
newInstance(menu, b);
|
BlockStorage.addBlockInfo(b, "round-robin", "false");
|
||||||
return false;
|
newInstance(menu, b);
|
||||||
});
|
return false;
|
||||||
}
|
});
|
||||||
else {
|
}
|
||||||
menu.replaceExistingItem(25, new CustomItem(new ItemStack(Material.MAP), "&7Include Lore: &4\u2718", "", "&e> Click to toggle whether the Lore has to match"));
|
|
||||||
menu.addMenuClickHandler(25, (p, slot, item, action) -> {
|
if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "filter-lore") == null || BlockStorage.getLocationInfo(b.getLocation(), "filter-lore").equals("true")) {
|
||||||
BlockStorage.addBlockInfo(b, "filter-lore", "true");
|
menu.replaceExistingItem(25, new CustomItem(new ItemStack(Material.MAP), "&7Include Lore: &2\u2714", "", "&e> Click to toggle whether the Lore has to match"));
|
||||||
newInstance(menu, b);
|
menu.addMenuClickHandler(25, (p, slot, item, action) -> {
|
||||||
return false;
|
BlockStorage.addBlockInfo(b, "filter-lore", "false");
|
||||||
});
|
newInstance(menu, b);
|
||||||
}
|
return false;
|
||||||
|
});
|
||||||
menu.replaceExistingItem(41, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjI1OTliZDk4NjY1OWI4Y2UyYzQ5ODg1MjVjOTRlMTlkZGQzOWZhZDA4YTM4Mjg0YTE5N2YxYjcwNjc1YWNjIn19fQ=="), "&bChannel", "", "&e> Click to decrease the Channel ID by 1"));
|
}
|
||||||
menu.addMenuClickHandler(41, (p, slot, item, action) -> {
|
else {
|
||||||
int channel = Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "frequency")) - 1;
|
menu.replaceExistingItem(25, new CustomItem(new ItemStack(Material.MAP), "&7Include Lore: &4\u2718", "", "&e> Click to toggle whether the Lore has to match"));
|
||||||
if (channel < 0) {
|
menu.addMenuClickHandler(25, (p, slot, item, action) -> {
|
||||||
if (CargoNet.EXTRA_CHANNELS) channel = 16;
|
BlockStorage.addBlockInfo(b, "filter-lore", "true");
|
||||||
else channel = 15;
|
newInstance(menu, b);
|
||||||
}
|
return false;
|
||||||
BlockStorage.addBlockInfo(b, "frequency", String.valueOf(channel));
|
});
|
||||||
newInstance(menu, b);
|
}
|
||||||
return false;
|
|
||||||
});
|
menu.replaceExistingItem(41, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjI1OTliZDk4NjY1OWI4Y2UyYzQ5ODg1MjVjOTRlMTlkZGQzOWZhZDA4YTM4Mjg0YTE5N2YxYjcwNjc1YWNjIn19fQ=="), "&bChannel", "", "&e> Click to decrease the Channel ID by 1"));
|
||||||
|
menu.addMenuClickHandler(41, (p, slot, item, action) -> {
|
||||||
int channel = ((!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "frequency") == null) ? 0: (Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "frequency"))));
|
int channel = Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "frequency")) - 1;
|
||||||
|
if (channel < 0) {
|
||||||
if (channel == 16) {
|
if (CargoNet.EXTRA_CHANNELS) channel = 16;
|
||||||
menu.replaceExistingItem(42, new CustomItem(SlimefunItems.CHEST_TERMINAL, "&bChannel ID: &3" + (channel + 1)));
|
else channel = 15;
|
||||||
menu.addMenuClickHandler(42,
|
}
|
||||||
(p, slot, item, action) -> false
|
BlockStorage.addBlockInfo(b, "frequency", String.valueOf(channel));
|
||||||
);
|
newInstance(menu, b);
|
||||||
}
|
return false;
|
||||||
else {
|
});
|
||||||
menu.replaceExistingItem(42, new CustomItem(new ItemStack(MaterialHelper.WoolColours[channel]), "&bChannel ID: &3" + (channel + 1)));
|
|
||||||
menu.addMenuClickHandler(42,
|
int channel = ((!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "frequency") == null) ? 0: (Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "frequency"))));
|
||||||
(p, slot, item, action) -> false
|
|
||||||
);
|
if (channel == 16) {
|
||||||
}
|
menu.replaceExistingItem(42, new CustomItem(SlimefunItems.CHEST_TERMINAL, "&bChannel ID: &3" + (channel + 1)));
|
||||||
|
menu.addMenuClickHandler(42,
|
||||||
menu.replaceExistingItem(43, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzJmOTEwYzQ3ZGEwNDJlNGFhMjhhZjZjYzgxY2Y0OGFjNmNhZjM3ZGFiMzVmODhkYjk5M2FjY2I5ZGZlNTE2In19fQ=="), "&bChannel", "", "&e> Click to increase the Channel ID by 1"));
|
(p, slot, item, action) -> false
|
||||||
menu.addMenuClickHandler(43, (p, slot, item, action) -> {
|
);
|
||||||
int channeln = Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "frequency")) + 1;
|
}
|
||||||
|
else {
|
||||||
if (CargoNet.EXTRA_CHANNELS) {
|
menu.replaceExistingItem(42, new CustomItem(new ItemStack(MaterialHelper.WoolColours[channel]), "&bChannel ID: &3" + (channel + 1)));
|
||||||
if (channeln > 16) channeln = 0;
|
menu.addMenuClickHandler(42,
|
||||||
}
|
(p, slot, item, action) -> false
|
||||||
else {
|
);
|
||||||
if (channeln > 15) channeln = 0;
|
}
|
||||||
}
|
|
||||||
|
menu.replaceExistingItem(43, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzJmOTEwYzQ3ZGEwNDJlNGFhMjhhZjZjYzgxY2Y0OGFjNmNhZjM3ZGFiMzVmODhkYjk5M2FjY2I5ZGZlNTE2In19fQ=="), "&bChannel", "", "&e> Click to increase the Channel ID by 1"));
|
||||||
BlockStorage.addBlockInfo(b, "frequency", String.valueOf(channeln));
|
menu.addMenuClickHandler(43, (p, slot, item, action) -> {
|
||||||
newInstance(menu, b);
|
int channeln = Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "frequency")) + 1;
|
||||||
return false;
|
|
||||||
});
|
if (CargoNet.EXTRA_CHANNELS) {
|
||||||
|
if (channeln > 16) channeln = 0;
|
||||||
} catch (Exception e) {
|
}
|
||||||
e.printStackTrace();
|
else {
|
||||||
}
|
if (channeln > 15) channeln = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
BlockStorage.addBlockInfo(b, "frequency", String.valueOf(channeln));
|
||||||
public boolean canOpen(Block b, Player p) {
|
newInstance(menu, b);
|
||||||
boolean open = CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b) || p.hasPermission("slimefun.cargo.bypass");
|
return false;
|
||||||
if (!open) {
|
});
|
||||||
Messages.local.sendTranslation(p, "inventory.no-access", true);
|
|
||||||
}
|
} catch (Exception e) {
|
||||||
return open;
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public int[] getSlotsAccessedByItemTransport(ItemTransportFlow flow) {
|
@Override
|
||||||
return new int[0];
|
public boolean canOpen(Block b, Player p) {
|
||||||
}
|
boolean open = CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b) || p.hasPermission("slimefun.cargo.bypass");
|
||||||
};
|
if (!open) {
|
||||||
|
Messages.local.sendTranslation(p, "inventory.no-access", true);
|
||||||
registerBlockHandler(name, new SlimefunBlockHandler() {
|
}
|
||||||
|
return open;
|
||||||
@Override
|
}
|
||||||
public void onPlace(Player p, Block b, SlimefunItem item) {
|
|
||||||
BlockStorage.addBlockInfo(b, "owner", p.getUniqueId().toString());
|
@Override
|
||||||
BlockStorage.addBlockInfo(b, "index", "0");
|
public int[] getSlotsAccessedByItemTransport(ItemTransportFlow flow) {
|
||||||
BlockStorage.addBlockInfo(b, "frequency", "0");
|
return new int[0];
|
||||||
BlockStorage.addBlockInfo(b, "filter-type", "whitelist");
|
}
|
||||||
BlockStorage.addBlockInfo(b, "filter-lore", "true");
|
};
|
||||||
BlockStorage.addBlockInfo(b, "filter-durability", "false");
|
|
||||||
BlockStorage.addBlockInfo(b, "round-robin", "false");
|
registerBlockHandler(name, new SlimefunBlockHandler() {
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public void onPlace(Player p, Block b, SlimefunItem item) {
|
||||||
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
|
BlockStorage.addBlockInfo(b, "owner", p.getUniqueId().toString());
|
||||||
BlockMenu inv = BlockStorage.getInventory(b);
|
BlockStorage.addBlockInfo(b, "index", "0");
|
||||||
if (inv != null) {
|
BlockStorage.addBlockInfo(b, "frequency", "0");
|
||||||
for (int slot : getInputSlots()) {
|
BlockStorage.addBlockInfo(b, "filter-type", "whitelist");
|
||||||
if (inv.getItemInSlot(slot) != null) {
|
BlockStorage.addBlockInfo(b, "filter-lore", "true");
|
||||||
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
|
BlockStorage.addBlockInfo(b, "filter-durability", "false");
|
||||||
inv.replaceExistingItem(slot, null);
|
BlockStorage.addBlockInfo(b, "round-robin", "false");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
@Override
|
||||||
return true;
|
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
|
||||||
}
|
BlockMenu inv = BlockStorage.getInventory(b);
|
||||||
});
|
if (inv != null) {
|
||||||
}
|
for (int slot : getInputSlots()) {
|
||||||
|
if (inv.getItemInSlot(slot) != null) {
|
||||||
protected void constructMenu(BlockMenuPreset preset) {
|
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
|
||||||
for (int i : border) {
|
inv.replaceExistingItem(slot, null);
|
||||||
preset.addItem(i, new CustomItem(new ItemStack(Material.CYAN_STAINED_GLASS_PANE), " "),
|
}
|
||||||
(p, slot, item, action) -> false
|
}
|
||||||
);
|
}
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
preset.addItem(2, new CustomItem(new ItemStack(Material.PAPER), "&3Items", "", "&bPut in all Items you want to", "&bblacklist/whitelist"),
|
});
|
||||||
(p, slot, item, action) -> false
|
}
|
||||||
);
|
|
||||||
}
|
protected void constructMenu(BlockMenuPreset preset) {
|
||||||
|
for (int i : border) {
|
||||||
public int[] getInputSlots() {
|
preset.addItem(i, new CustomItem(new ItemStack(Material.CYAN_STAINED_GLASS_PANE), " "),
|
||||||
return new int[] {19, 20, 21, 28, 29, 30, 37, 38, 39};
|
(p, slot, item, action) -> false
|
||||||
}
|
);
|
||||||
|
}
|
||||||
}
|
|
||||||
|
preset.addItem(2, new CustomItem(new ItemStack(Material.PAPER), "&3Items", "", "&bPut in all Items you want to", "&bblacklist/whitelist"),
|
||||||
|
(p, slot, item, action) -> false
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int[] getInputSlots() {
|
||||||
|
return new int[] {19, 20, 21, 28, 29, 30, 37, 38, 39};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user