1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-19 19:25:48 +00:00

Merge remote-tracking branch 'upstream/master'

Conflicts:
	src/me/mrCookieSlime/Slimefun/listeners/AncientAltarListener.java
This commit is contained in:
BuildTools 2016-11-13 18:28:21 +01:00
commit 06e1424db1
7 changed files with 260 additions and 234 deletions

View File

@ -1,124 +1,149 @@
package me.mrCookieSlime.CSCoreLibSetup;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import org.bukkit.plugin.Plugin;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
public class CSCoreLibLoader {
Plugin plugin;
URL url;
URL download;
File file;
public CSCoreLibLoader(Plugin plugin) {
this.plugin = plugin;
try {
this.url = new URL("https://api.curseforge.com/servermods/files?projectIds=88802");
} catch (MalformedURLException e) {
}
}
public boolean load() {
if (plugin.getServer().getPluginManager().isPluginEnabled("CS-CoreLib")) return true;
else {
System.err.println(" ");
System.err.println("#################### - FATAL ERROR - ####################");
System.err.println(" ");
System.err.println(plugin.getName() + " could not be properly installed!");
System.err.println("It appears that you have not installed CS-CoreLib");
System.err.println("And because of that, CS-CoreLib is now going to be");
System.err.println("downloaded and installed.");
System.err.println("But for the time being " + plugin.getName() + " will remain disabled");
System.err.println("After the installation process has finished,");
System.out.println("you will be asked to restart your Server.");
System.err.println("- mrCookieSlime");
System.err.println(" ");
System.err.println("#################### - FATAL ERROR - ####################");
System.err.println(" ");
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
if (connect()) install();
}
}, 10L);
return false;
}
}
private boolean connect() {
try {
final URLConnection connection = this.url.openConnection();
connection.setConnectTimeout(5000);
connection.addRequestProperty("User-Agent", "CS-CoreLib Loader (by mrCookieSlime)");
connection.setDoOutput(true);
final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
final JSONArray array = (JSONArray) JSONValue.parse(reader.readLine());
download = new URL((String) ((JSONObject) array.get(array.size() - 1)).get("downloadUrl"));
file = new File("plugins/" + (String) ((JSONObject) array.get(array.size() - 1)).get("name") + ".jar");
return true;
} catch (IOException e) {
System.err.println(" ");
System.err.println("#################### - FATAL ERROR - ####################");
System.err.println(" ");
System.err.println("Could not connect to BukkitDev, is it down?");
System.err.println(" ");
System.err.println("#################### - FATAL ERROR - ####################");
System.err.println(" ");
return false;
}
}
private void install() {
BufferedInputStream input = null;
FileOutputStream output = null;
try {
input = new BufferedInputStream(download.openStream());
output = new FileOutputStream(file);
final byte[] data = new byte[1024];
int read;
while ((read = input.read(data, 0, 1024)) != -1) {
output.write(data, 0, read);
}
} catch (Exception ex) {
System.err.println(" ");
System.err.println("#################### - FATAL ERROR - ####################");
System.err.println(" ");
System.err.println("Could not download CS-CoreLib");
System.err.println(" ");
System.err.println("#################### - FATAL ERROR - ####################");
System.err.println(" ");
} finally {
try {
if (input != null) input.close();
if (output != null) output.close();
System.err.println(" ");
System.err.println("#################### - WARNING - ####################");
System.err.println(" ");
System.err.println("Please restart your Server to finish the Installation");
System.err.println("of " + plugin.getName() + " and CS-CoreLib");
System.err.println(" ");
System.err.println("#################### - WARNING - ####################");
System.err.println(" ");
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
package me.mrCookieSlime.CSCoreLibSetup;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import org.bukkit.plugin.Plugin;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
public class CSCoreLibLoader {
Plugin plugin;
URL url;
URL download;
File file;
public CSCoreLibLoader(Plugin plugin) {
this.plugin = plugin;
try {
this.url = new URL("https://api.curseforge.com/servermods/files?projectIds=88802");
} catch (MalformedURLException e) {
}
}
public boolean load() {
if (plugin.getServer().getPluginManager().isPluginEnabled("CS-CoreLib")) return true;
else {
System.err.println(" ");
System.err.println("#################### - FATAL ERROR - ####################");
System.err.println(" ");
System.err.println(plugin.getName() + " could not be properly installed!");
System.err.println("It appears that you have not installed CS-CoreLib");
System.err.println("And because of that, CS-CoreLib is now going to be");
System.err.println("downloaded and installed.");
System.err.println("But for the time being " + plugin.getName() + " will remain disabled");
System.err.println("After the installation process has finished,");
System.out.println("you will be asked to restart your Server.");
System.err.println("- mrCookieSlime");
System.err.println(" ");
System.err.println("#################### - FATAL ERROR - ####################");
System.err.println(" ");
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
if (connect()) install();
}
}, 10L);
return false;
}
}
private boolean connect() {
try {
final URLConnection connection = this.url.openConnection();
connection.setConnectTimeout(5000);
connection.addRequestProperty("User-Agent", "CS-CoreLib Loader (by mrCookieSlime)");
connection.setDoOutput(true);
final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
final JSONArray array = (JSONArray) JSONValue.parse(reader.readLine());
download = traceURL(((String) ((JSONObject) array.get(array.size() - 1)).get("downloadUrl")).replace("https:", "http:"));
file = new File("plugins/" + (String) ((JSONObject) array.get(array.size() - 1)).get("name") + ".jar");
return true;
} catch (IOException e) {
System.err.println(" ");
System.err.println("#################### - FATAL ERROR - ####################");
System.err.println(" ");
System.err.println("Could not connect to BukkitDev, is it down?");
System.err.println(" ");
System.err.println("#################### - FATAL ERROR - ####################");
System.err.println(" ");
return false;
}
}
private URL traceURL(String location) throws IOException {
HttpURLConnection connection = null;
while (true) {
URL url = new URL(location);
connection = (HttpURLConnection) url.openConnection();
connection.setInstanceFollowRedirects(false);
connection.setConnectTimeout(5000);
connection.addRequestProperty("User-Agent", "Auto Updater (by mrCookieSlime)");
switch (connection.getResponseCode()) {
case HttpURLConnection.HTTP_MOVED_PERM:
case HttpURLConnection.HTTP_MOVED_TEMP:
String loc = connection.getHeaderField("Location");
location = new URL(new URL(location), loc).toExternalForm();
continue;
}
break;
}
return connection.getURL();
}
private void install() {
BufferedInputStream input = null;
FileOutputStream output = null;
try {
input = new BufferedInputStream(download.openStream());
output = new FileOutputStream(file);
final byte[] data = new byte[1024];
int read;
while ((read = input.read(data, 0, 1024)) != -1) {
output.write(data, 0, read);
}
} catch (Exception ex) {
System.err.println(" ");
System.err.println("#################### - FATAL ERROR - ####################");
System.err.println(" ");
System.err.println("Could not download CS-CoreLib");
System.err.println(" ");
System.err.println("#################### - FATAL ERROR - ####################");
System.err.println(" ");
} finally {
try {
if (input != null) input.close();
if (output != null) output.close();
System.err.println(" ");
System.err.println("#################### - WARNING - ####################");
System.err.println(" ");
System.err.println("Please restart your Server to finish the Installation");
System.err.println("of " + plugin.getName() + " and CS-CoreLib");
System.err.println(" ");
System.err.println("#################### - WARNING - ####################");
System.err.println(" ");
} catch (IOException e) {
e.printStackTrace();
}
}
}
}

View File

@ -1,5 +1,12 @@
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
@ -10,18 +17,13 @@ import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.UnregisterReason;
import me.mrCookieSlime.Slimefun.Setup.Messages;
import me.mrCookieSlime.Slimefun.api.BlockStorage;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
import me.mrCookieSlime.Slimefun.api.item_transport.CargoNet;
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
public class AdvancedCargoOutputNode extends SlimefunItem {
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};
@ -29,7 +31,7 @@ public class AdvancedCargoOutputNode extends SlimefunItem {
public AdvancedCargoOutputNode(Category category, ItemStack item, String name, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) {
super(category, item, name, recipeType, recipe, recipeOutput);
new BlockMenuPreset(name, "§cOutput Node") {
new BlockMenuPreset(name, "§cOutput Node") {
@Override
public void init() {
@ -41,7 +43,7 @@ public class AdvancedCargoOutputNode extends SlimefunItem {
public void newInstance(final BlockMenu menu, final Block b) {
try {
if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getBlockInfo(b, "filter-type") == null || BlockStorage.getBlockInfo(b, "filter-type").equals("whitelist")) {
menu.replaceExistingItem(15, new CustomItem(new MaterialData(Material.WOOL), "§7Type: §rWhitelist", "", "§e> Click to change it to Blacklist"));
menu.replaceExistingItem(15, new CustomItem(new MaterialData(Material.WOOL), "§7Type: §rWhitelist", "", "§e> Click to change it to Blacklist"));
menu.addMenuClickHandler(15, new MenuClickHandler() {
@Override
@ -53,7 +55,7 @@ public class AdvancedCargoOutputNode extends SlimefunItem {
});
}
else {
menu.replaceExistingItem(15, new CustomItem(new MaterialData(Material.WOOL, (byte) 15), "§7Type: §8Blacklist", "", "§e> Click to change it to Whitelist"));
menu.replaceExistingItem(15, new CustomItem(new MaterialData(Material.WOOL, (byte) 15), "§7Type: §8Blacklist", "", "§e> Click to change it to Whitelist"));
menu.addMenuClickHandler(15, new MenuClickHandler() {
@Override
@ -66,7 +68,7 @@ public class AdvancedCargoOutputNode extends SlimefunItem {
}
if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getBlockInfo(b, "filter-durability") == null || BlockStorage.getBlockInfo(b, "filter-durability").equals("false")) {
menu.replaceExistingItem(16, new CustomItem(new MaterialData(Material.STONE_SWORD, (byte) 20), "§7Include Sub-IDs/Durability: §4\u2718", "", "§e> Click to toggle whether the Durability has to match"));
menu.replaceExistingItem(16, new CustomItem(new MaterialData(Material.STONE_SWORD, (byte) 20), "§7Include Sub-IDs/Durability: §4\u2718", "", "§e> Click to toggle whether the Durability has to match"));
menu.addMenuClickHandler(16, new MenuClickHandler() {
@Override
@ -78,7 +80,7 @@ public class AdvancedCargoOutputNode extends SlimefunItem {
});
}
else {
menu.replaceExistingItem(16, new CustomItem(new MaterialData(Material.GOLD_SWORD, (byte) 20), "§7Include Sub-IDs/Durability: §2\u2714", "", "§e> Click to toggle whether the Durability has to match"));
menu.replaceExistingItem(16, new CustomItem(new MaterialData(Material.GOLD_SWORD, (byte) 20), "§7Include Sub-IDs/Durability: §2\u2714", "", "§e> Click to toggle whether the Durability has to match"));
menu.addMenuClickHandler(16, new MenuClickHandler() {
@Override
@ -91,7 +93,7 @@ public class AdvancedCargoOutputNode extends SlimefunItem {
}
if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getBlockInfo(b, "filter-lore") == null || BlockStorage.getBlockInfo(b, "filter-lore").equals("true")) {
menu.replaceExistingItem(25, new CustomItem(new MaterialData(Material.EMPTY_MAP), "§7Include Lore: §2\u2714", "", "§e> Click to toggle whether the Lore has to match"));
menu.replaceExistingItem(25, new CustomItem(new MaterialData(Material.EMPTY_MAP), "§7Include Lore: §2\u2714", "", "§e> Click to toggle whether the Lore has to match"));
menu.addMenuClickHandler(25, new MenuClickHandler() {
@Override
@ -103,7 +105,7 @@ public class AdvancedCargoOutputNode extends SlimefunItem {
});
}
else {
menu.replaceExistingItem(25, new CustomItem(new MaterialData(Material.EMPTY_MAP), "§7Include Lore: §4\u2718", "", "§e> Click to toggle whether the Lore has to match"));
menu.replaceExistingItem(25, new CustomItem(new MaterialData(Material.EMPTY_MAP), "§7Include Lore: §4\u2718", "", "§e> Click to toggle whether the Lore has to match"));
menu.addMenuClickHandler(25, new MenuClickHandler() {
@Override
@ -115,7 +117,7 @@ public class AdvancedCargoOutputNode extends SlimefunItem {
});
}
menu.replaceExistingItem(41, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjI1OTliZDk4NjY1OWI4Y2UyYzQ5ODg1MjVjOTRlMTlkZGQzOWZhZDA4YTM4Mjg0YTE5N2YxYjcwNjc1YWNjIn19fQ=="), "§bChannel", "", "§e> Click to decrease the Channel ID by 1"));
menu.replaceExistingItem(41, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjI1OTliZDk4NjY1OWI4Y2UyYzQ5ODg1MjVjOTRlMTlkZGQzOWZhZDA4YTM4Mjg0YTE5N2YxYjcwNjc1YWNjIn19fQ=="), "§bChannel", "", "§e> Click to decrease the Channel ID by 1"));
menu.addMenuClickHandler(41, new MenuClickHandler() {
@Override
@ -134,7 +136,7 @@ public class AdvancedCargoOutputNode extends SlimefunItem {
int channel = ((!BlockStorage.hasBlockInfo(b) || BlockStorage.getBlockInfo(b, "frequency") == null) ? 0: (Integer.parseInt(BlockStorage.getBlockInfo(b, "frequency"))));
if (channel == 16) {
menu.replaceExistingItem(42, new CustomItem(SlimefunItems.CHEST_TERMINAL, "§bChannel ID: §3" + (channel + 1)));
menu.replaceExistingItem(42, new CustomItem(SlimefunItems.CHEST_TERMINAL, "§bChannel ID: §3" + (channel + 1)));
menu.addMenuClickHandler(42, new MenuClickHandler() {
@Override
@ -144,7 +146,7 @@ public class AdvancedCargoOutputNode extends SlimefunItem {
});
}
else {
menu.replaceExistingItem(42, new CustomItem(new MaterialData(Material.WOOL, (byte) channel), "§bChannel ID: §3" + (channel + 1)));
menu.replaceExistingItem(42, new CustomItem(new MaterialData(Material.WOOL, (byte) channel), "§bChannel ID: §3" + (channel + 1)));
menu.addMenuClickHandler(42, new MenuClickHandler() {
@Override
@ -154,7 +156,7 @@ public class AdvancedCargoOutputNode extends SlimefunItem {
});
}
menu.replaceExistingItem(43, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzJmOTEwYzQ3ZGEwNDJlNGFhMjhhZjZjYzgxY2Y0OGFjNmNhZjM3ZGFiMzVmODhkYjk5M2FjY2I5ZGZlNTE2In19fQ=="), "§bChannel", "", "§e> Click to increase the Channel ID by 1"));
menu.replaceExistingItem(43, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzJmOTEwYzQ3ZGEwNDJlNGFhMjhhZjZjYzgxY2Y0OGFjNmNhZjM3ZGFiMzVmODhkYjk5M2FjY2I5ZGZlNTE2In19fQ=="), "§bChannel", "", "§e> Click to increase the Channel ID by 1"));
menu.addMenuClickHandler(43, new MenuClickHandler() {
@Override
@ -181,7 +183,11 @@ public class AdvancedCargoOutputNode extends SlimefunItem {
@Override
public boolean canOpen(Block b, Player p) {
return BlockStorage.getBlockInfo(b, "owner").equals(p.getUniqueId().toString()) || p.hasPermission("slimefun.cargo.bypass");
boolean open = CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b) || p.hasPermission("slimefun.cargo.bypass");
if (!open) {
Messages.local.sendTranslation(p, "inventory.no-access", true);
}
return open;
}
@Override
@ -226,7 +232,7 @@ public class AdvancedCargoOutputNode extends SlimefunItem {
});
}
preset.addItem(2, new CustomItem(new MaterialData(Material.PAPER), "§3Items", "", "§bPut in all Items you want to", "§bblacklist/whitelist"),
preset.addItem(2, new CustomItem(new MaterialData(Material.PAPER), "§3Items", "", "§bPut in all Items you want to", "§bblacklist/whitelist"),
new MenuClickHandler() {
@Override

View File

@ -1,5 +1,12 @@
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
@ -15,12 +22,6 @@ import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
public class CargoCraftingNode extends SlimefunItem {
private static final int[] border = {0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 22, 23, 24, 25, 26, 27, 31, 32, 33, 34, 35, 36, 40, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53};
@ -28,7 +29,7 @@ public class CargoCraftingNode extends SlimefunItem {
public CargoCraftingNode(Category category, ItemStack item, String name, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, name, recipeType, recipe);
new BlockMenuPreset(name, "§3Input Node") {
new BlockMenuPreset(name, "§3Input Node") {
@Override
public void init() {
@ -39,7 +40,7 @@ public class CargoCraftingNode extends SlimefunItem {
@Override
public void newInstance(final BlockMenu menu, final Block b) {
try {
menu.replaceExistingItem(41, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjI1OTliZDk4NjY1OWI4Y2UyYzQ5ODg1MjVjOTRlMTlkZGQzOWZhZDA4YTM4Mjg0YTE5N2YxYjcwNjc1YWNjIn19fQ=="), "§bChannel", "", "§e> Click to decrease the Channel ID by 1"));
menu.replaceExistingItem(41, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjI1OTliZDk4NjY1OWI4Y2UyYzQ5ODg1MjVjOTRlMTlkZGQzOWZhZDA4YTM4Mjg0YTE5N2YxYjcwNjc1YWNjIn19fQ=="), "§bChannel", "", "§e> Click to decrease the Channel ID by 1"));
menu.addMenuClickHandler(41, new MenuClickHandler() {
@Override
@ -52,7 +53,7 @@ public class CargoCraftingNode extends SlimefunItem {
}
});
menu.replaceExistingItem(42, new CustomItem(new MaterialData(Material.WOOL, (byte) ((!BlockStorage.hasBlockInfo(b) || BlockStorage.getBlockInfo(b, "frequency") == null) ? 0: (Integer.parseInt(BlockStorage.getBlockInfo(b, "frequency"))))), "§bChannel ID: §3" + (((!BlockStorage.hasBlockInfo(b) || BlockStorage.getBlockInfo(b, "frequency") == null) ? 0: (Integer.parseInt(BlockStorage.getBlockInfo(b, "frequency")))) + 1)));
menu.replaceExistingItem(42, new CustomItem(new MaterialData(Material.WOOL, (byte) ((!BlockStorage.hasBlockInfo(b) || BlockStorage.getBlockInfo(b, "frequency") == null) ? 0: (Integer.parseInt(BlockStorage.getBlockInfo(b, "frequency"))))), "§bChannel ID: §3" + (((!BlockStorage.hasBlockInfo(b) || BlockStorage.getBlockInfo(b, "frequency") == null) ? 0: (Integer.parseInt(BlockStorage.getBlockInfo(b, "frequency")))) + 1)));
menu.addMenuClickHandler(42, new MenuClickHandler() {
@Override
@ -61,7 +62,7 @@ public class CargoCraftingNode extends SlimefunItem {
}
});
menu.replaceExistingItem(43, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzJmOTEwYzQ3ZGEwNDJlNGFhMjhhZjZjYzgxY2Y0OGFjNmNhZjM3ZGFiMzVmODhkYjk5M2FjY2I5ZGZlNTE2In19fQ=="), "§bChannel", "", "§e> Click to increase the Channel ID by 1"));
menu.replaceExistingItem(43, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzJmOTEwYzQ3ZGEwNDJlNGFhMjhhZjZjYzgxY2Y0OGFjNmNhZjM3ZGFiMzVmODhkYjk5M2FjY2I5ZGZlNTE2In19fQ=="), "§bChannel", "", "§e> Click to increase the Channel ID by 1"));
menu.addMenuClickHandler(43, new MenuClickHandler() {
@Override
@ -81,7 +82,7 @@ public class CargoCraftingNode extends SlimefunItem {
@Override
public boolean canOpen(Block b, Player p) {
boolean open = BlockStorage.getBlockInfo(b, "owner").equals(p.getUniqueId().toString()) || p.hasPermission("slimefun.cargo.bypass");
boolean open = CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b) || p.hasPermission("slimefun.cargo.bypass");
if (!open) {
Messages.local.sendTranslation(p, "inventory.no-access", true);
}
@ -126,7 +127,7 @@ public class CargoCraftingNode extends SlimefunItem {
});
}
preset.addItem(2, new CustomItem(new MaterialData(Material.WORKBENCH), "§eRecipe", "", "§bPut in the Recipe you want to craft"),
preset.addItem(2, new CustomItem(new MaterialData(Material.WORKBENCH), "§eRecipe", "", "§bPut in the Recipe you want to craft"),
new MenuClickHandler() {
@Override

View File

@ -1,5 +1,12 @@
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
@ -17,12 +24,6 @@ import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
import me.mrCookieSlime.Slimefun.api.item_transport.CargoNet;
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
public class CargoInputNode extends SlimefunItem {
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};
@ -30,7 +31,7 @@ public class CargoInputNode extends SlimefunItem {
public CargoInputNode(Category category, ItemStack item, String name, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) {
super(category, item, name, recipeType, recipe, recipeOutput);
new BlockMenuPreset(name, "§3Input Node") {
new BlockMenuPreset(name, "§3Input Node") {
@Override
public void init() {
@ -42,7 +43,7 @@ public class CargoInputNode extends SlimefunItem {
public void newInstance(final BlockMenu menu, final Block b) {
try {
if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getBlockInfo(b, "filter-type") == null || BlockStorage.getBlockInfo(b, "filter-type").equals("whitelist")) {
menu.replaceExistingItem(15, new CustomItem(new MaterialData(Material.WOOL), "§7Type: §rWhitelist", "", "§e> Click to change it to Blacklist"));
menu.replaceExistingItem(15, new CustomItem(new MaterialData(Material.WOOL), "§7Type: §rWhitelist", "", "§e> Click to change it to Blacklist"));
menu.addMenuClickHandler(15, new MenuClickHandler() {
@Override
@ -54,7 +55,7 @@ public class CargoInputNode extends SlimefunItem {
});
}
else {
menu.replaceExistingItem(15, new CustomItem(new MaterialData(Material.WOOL, (byte) 15), "§7Type: §8Blacklist", "", "§e> Click to change it to Whitelist"));
menu.replaceExistingItem(15, new CustomItem(new MaterialData(Material.WOOL, (byte) 15), "§7Type: §8Blacklist", "", "§e> Click to change it to Whitelist"));
menu.addMenuClickHandler(15, new MenuClickHandler() {
@Override
@ -67,7 +68,7 @@ public class CargoInputNode extends SlimefunItem {
}
if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getBlockInfo(b, "filter-durability") == null || BlockStorage.getBlockInfo(b, "filter-durability").equals("false")) {
menu.replaceExistingItem(16, new CustomItem(new MaterialData(Material.STONE_SWORD, (byte) 20), "§7Include Sub-IDs/Durability: §4\u2718", "", "§e> Click to toggle whether the Durability has to match"));
menu.replaceExistingItem(16, new CustomItem(new MaterialData(Material.STONE_SWORD, (byte) 20), "§7Include Sub-IDs/Durability: §4\u2718", "", "§e> Click to toggle whether the Durability has to match"));
menu.addMenuClickHandler(16, new MenuClickHandler() {
@Override
@ -79,7 +80,7 @@ public class CargoInputNode extends SlimefunItem {
});
}
else {
menu.replaceExistingItem(16, new CustomItem(new MaterialData(Material.GOLD_SWORD, (byte) 20), "§7Include Sub-IDs/Durability: §2\u2714", "", "§e> Click to toggle whether the Durability has to match"));
menu.replaceExistingItem(16, new CustomItem(new MaterialData(Material.GOLD_SWORD, (byte) 20), "§7Include Sub-IDs/Durability: §2\u2714", "", "§e> Click to toggle whether the Durability has to match"));
menu.addMenuClickHandler(16, new MenuClickHandler() {
@Override
@ -92,7 +93,7 @@ public class CargoInputNode extends SlimefunItem {
}
if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getBlockInfo(b, "round-robin") == null || BlockStorage.getBlockInfo(b, "round-robin").equals("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)"));
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)"));
menu.addMenuClickHandler(24, new MenuClickHandler() {
@Override
@ -104,7 +105,7 @@ public class CargoInputNode extends SlimefunItem {
});
}
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.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, new MenuClickHandler() {
@Override
@ -117,7 +118,7 @@ public class CargoInputNode extends SlimefunItem {
}
if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getBlockInfo(b, "filter-lore") == null || BlockStorage.getBlockInfo(b, "filter-lore").equals("true")) {
menu.replaceExistingItem(25, new CustomItem(new MaterialData(Material.EMPTY_MAP), "§7Include Lore: §2\u2714", "", "§e> Click to toggle whether the Lore has to match"));
menu.replaceExistingItem(25, new CustomItem(new MaterialData(Material.EMPTY_MAP), "§7Include Lore: §2\u2714", "", "§e> Click to toggle whether the Lore has to match"));
menu.addMenuClickHandler(25, new MenuClickHandler() {
@Override
@ -129,7 +130,7 @@ public class CargoInputNode extends SlimefunItem {
});
}
else {
menu.replaceExistingItem(25, new CustomItem(new MaterialData(Material.EMPTY_MAP), "§7Include Lore: §4\u2718", "", "§e> Click to toggle whether the Lore has to match"));
menu.replaceExistingItem(25, new CustomItem(new MaterialData(Material.EMPTY_MAP), "§7Include Lore: §4\u2718", "", "§e> Click to toggle whether the Lore has to match"));
menu.addMenuClickHandler(25, new MenuClickHandler() {
@Override
@ -141,7 +142,7 @@ public class CargoInputNode extends SlimefunItem {
});
}
menu.replaceExistingItem(41, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjI1OTliZDk4NjY1OWI4Y2UyYzQ5ODg1MjVjOTRlMTlkZGQzOWZhZDA4YTM4Mjg0YTE5N2YxYjcwNjc1YWNjIn19fQ=="), "§bChannel", "", "§e> Click to decrease the Channel ID by 1"));
menu.replaceExistingItem(41, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjI1OTliZDk4NjY1OWI4Y2UyYzQ5ODg1MjVjOTRlMTlkZGQzOWZhZDA4YTM4Mjg0YTE5N2YxYjcwNjc1YWNjIn19fQ=="), "§bChannel", "", "§e> Click to decrease the Channel ID by 1"));
menu.addMenuClickHandler(41, new MenuClickHandler() {
@Override
@ -160,7 +161,7 @@ public class CargoInputNode extends SlimefunItem {
int channel = ((!BlockStorage.hasBlockInfo(b) || BlockStorage.getBlockInfo(b, "frequency") == null) ? 0: (Integer.parseInt(BlockStorage.getBlockInfo(b, "frequency"))));
if (channel == 16) {
menu.replaceExistingItem(42, new CustomItem(SlimefunItems.CHEST_TERMINAL, "§bChannel ID: §3" + (channel + 1)));
menu.replaceExistingItem(42, new CustomItem(SlimefunItems.CHEST_TERMINAL, "§bChannel ID: §3" + (channel + 1)));
menu.addMenuClickHandler(42, new MenuClickHandler() {
@Override
@ -170,7 +171,7 @@ public class CargoInputNode extends SlimefunItem {
});
}
else {
menu.replaceExistingItem(42, new CustomItem(new MaterialData(Material.WOOL, (byte) channel), "§bChannel ID: §3" + (channel + 1)));
menu.replaceExistingItem(42, new CustomItem(new MaterialData(Material.WOOL, (byte) channel), "§bChannel ID: §3" + (channel + 1)));
menu.addMenuClickHandler(42, new MenuClickHandler() {
@Override
@ -180,7 +181,7 @@ public class CargoInputNode extends SlimefunItem {
});
}
menu.replaceExistingItem(43, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzJmOTEwYzQ3ZGEwNDJlNGFhMjhhZjZjYzgxY2Y0OGFjNmNhZjM3ZGFiMzVmODhkYjk5M2FjY2I5ZGZlNTE2In19fQ=="), "§bChannel", "", "§e> Click to increase the Channel ID by 1"));
menu.replaceExistingItem(43, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzJmOTEwYzQ3ZGEwNDJlNGFhMjhhZjZjYzgxY2Y0OGFjNmNhZjM3ZGFiMzVmODhkYjk5M2FjY2I5ZGZlNTE2In19fQ=="), "§bChannel", "", "§e> Click to increase the Channel ID by 1"));
menu.addMenuClickHandler(43, new MenuClickHandler() {
@Override
@ -207,7 +208,7 @@ public class CargoInputNode extends SlimefunItem {
@Override
public boolean canOpen(Block b, Player p) {
boolean open = BlockStorage.getBlockInfo(b, "owner").equals(p.getUniqueId().toString()) || p.hasPermission("slimefun.cargo.bypass");
boolean open = CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b) || p.hasPermission("slimefun.cargo.bypass");
if (!open) {
Messages.local.sendTranslation(p, "inventory.no-access", true);
}
@ -257,7 +258,7 @@ public class CargoInputNode extends SlimefunItem {
});
}
preset.addItem(2, new CustomItem(new MaterialData(Material.PAPER), "§3Items", "", "§bPut in all Items you want to", "§bblacklist/whitelist"),
preset.addItem(2, new CustomItem(new MaterialData(Material.PAPER), "§3Items", "", "§bPut in all Items you want to", "§bblacklist/whitelist"),
new MenuClickHandler() {
@Override

View File

@ -1,5 +1,12 @@
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
@ -17,12 +24,6 @@ import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
import me.mrCookieSlime.Slimefun.api.item_transport.CargoNet;
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
public class CargoOutputNode extends SlimefunItem {
private static final int[] border = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26};
@ -30,7 +31,7 @@ public class CargoOutputNode extends SlimefunItem {
public CargoOutputNode(Category category, ItemStack item, String name, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) {
super(category, item, name, recipeType, recipe, recipeOutput);
new BlockMenuPreset(name, "§6Output Node") {
new BlockMenuPreset(name, "§6Output Node") {
@Override
public void init() {
@ -42,7 +43,7 @@ public class CargoOutputNode extends SlimefunItem {
public void newInstance(final BlockMenu menu, final Block b) {
try {
menu.replaceExistingItem(12, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjI1OTliZDk4NjY1OWI4Y2UyYzQ5ODg1MjVjOTRlMTlkZGQzOWZhZDA4YTM4Mjg0YTE5N2YxYjcwNjc1YWNjIn19fQ=="), "§bChannel", "", "§e> Click to decrease the Channel ID by 1"));
menu.replaceExistingItem(12, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjI1OTliZDk4NjY1OWI4Y2UyYzQ5ODg1MjVjOTRlMTlkZGQzOWZhZDA4YTM4Mjg0YTE5N2YxYjcwNjc1YWNjIn19fQ=="), "§bChannel", "", "§e> Click to decrease the Channel ID by 1"));
menu.addMenuClickHandler(12, new MenuClickHandler() {
@Override
@ -61,7 +62,7 @@ public class CargoOutputNode extends SlimefunItem {
int channel = ((!BlockStorage.hasBlockInfo(b) || BlockStorage.getBlockInfo(b, "frequency") == null) ? 0: (Integer.parseInt(BlockStorage.getBlockInfo(b, "frequency"))));
if (channel == 16) {
menu.replaceExistingItem(13, new CustomItem(SlimefunItems.CHEST_TERMINAL, "§bChannel ID: §3" + (channel + 1)));
menu.replaceExistingItem(13, new CustomItem(SlimefunItems.CHEST_TERMINAL, "§bChannel ID: §3" + (channel + 1)));
menu.addMenuClickHandler(13, new MenuClickHandler() {
@Override
@ -71,7 +72,7 @@ public class CargoOutputNode extends SlimefunItem {
});
}
else {
menu.replaceExistingItem(13, new CustomItem(new MaterialData(Material.WOOL, (byte) channel), "§bChannel ID: §3" + (channel + 1)));
menu.replaceExistingItem(13, new CustomItem(new MaterialData(Material.WOOL, (byte) channel), "§bChannel ID: §3" + (channel + 1)));
menu.addMenuClickHandler(13, new MenuClickHandler() {
@Override
@ -81,7 +82,7 @@ public class CargoOutputNode extends SlimefunItem {
});
}
menu.replaceExistingItem(14, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzJmOTEwYzQ3ZGEwNDJlNGFhMjhhZjZjYzgxY2Y0OGFjNmNhZjM3ZGFiMzVmODhkYjk5M2FjY2I5ZGZlNTE2In19fQ=="), "§bChannel", "", "§e> Click to increase the Channel ID by 1"));
menu.replaceExistingItem(14, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzJmOTEwYzQ3ZGEwNDJlNGFhMjhhZjZjYzgxY2Y0OGFjNmNhZjM3ZGFiMzVmODhkYjk5M2FjY2I5ZGZlNTE2In19fQ=="), "§bChannel", "", "§e> Click to increase the Channel ID by 1"));
menu.addMenuClickHandler(14, new MenuClickHandler() {
@Override
@ -108,7 +109,7 @@ public class CargoOutputNode extends SlimefunItem {
@Override
public boolean canOpen(Block b, Player p) {
boolean open = BlockStorage.getBlockInfo(b, "owner").equals(p.getUniqueId().toString()) || p.hasPermission("slimefun.cargo.bypass");
boolean open = CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b) || p.hasPermission("slimefun.cargo.bypass");
if (!open) {
Messages.local.sendTranslation(p, "inventory.no-access", true);
}

View File

@ -28,7 +28,6 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.inventory.InventoryPickupItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.inventory.ItemStack;
@ -37,14 +36,14 @@ import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.util.Vector;
public class AncientAltarListener implements Listener {
public AncientAltarListener(SlimefunStartup plugin) {
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
List<Block> altars = new ArrayList<Block>();
Set<UUID> removed_items = new HashSet<UUID>();
@EventHandler(priority=EventPriority.HIGH)
public void onInteract(PlayerInteractEvent e) {
if (e.getAction() != Action.RIGHT_CLICK_BLOCK) return;
@ -60,9 +59,9 @@ public class AncientAltarListener implements Listener {
else if (!removed_items.contains(stack.getUniqueId())) {
final UUID uuid = stack.getUniqueId();
removed_items.add(uuid);
SlimefunStartup.instance.getServer().getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, new Runnable() {
@Override
public void run() {
removed_items.remove(uuid);
@ -77,10 +76,10 @@ public class AncientAltarListener implements Listener {
}
else if (item.getName().equals("ANCIENT_ALTAR")) {
e.setCancelled(true);
ItemStack catalyst = e.getPlayer().getInventory().getItemInMainHand();
ItemStack catalyst = new CustomItem(e.getPlayer().getInventory().getItemInMainHand(), 1);
List<Block> pedestals = Pedestals.getPedestals(b);
if (!altars.contains(e.getClickedBlock())) {
altars.add(e.getClickedBlock());
if (pedestals.size() == 8) {
@ -90,7 +89,7 @@ public class AncientAltarListener implements Listener {
Item stack = findItem(pedestal);
if (stack != null) input.add(fixItemStack(stack.getItemStack(), stack.getCustomName()));
}
ItemStack result = Pedestals.getRecipeOutput(catalyst, input);
if (result != null) {
List<ItemStack> consumed = new ArrayList<ItemStack>();
@ -116,7 +115,7 @@ public class AncientAltarListener implements Listener {
}
}
}
private ItemStack fixItemStack(ItemStack itemStack, String customName) {
ItemStack stack = itemStack.clone();
if (customName.equals(StringUtils.formatItemName(itemStack.getData().toItemStack(1), false))) {
@ -146,7 +145,7 @@ public class AncientAltarListener implements Listener {
if (stack != null && !stack.getType().equals(Material.AIR)) {
PlayerInventory.consumeItemInHand(p);
String nametag = StringUtils.formatItemName(stack, false);
Item entity = b.getWorld().dropItem(b.getLocation().add(0.5, 1.2, 0.5), new CustomItem(new CustomItem(stack, 1), "§5§dALTAR §3Probe - §e" + System.nanoTime()));
Item entity = b.getWorld().dropItem(b.getLocation().add(0.5, 1.2, 0.5), new CustomItem(new CustomItem(stack, 1), "§5§dALTAR §3Probe - §e" + System.nanoTime()));
entity.setVelocity(new Vector(0, 0.1, 0));
entity.setMetadata("no_pickup", new FixedMetadataValue(SlimefunStartup.instance, "altar_item"));
entity.setCustomNameVisible(true);
@ -158,16 +157,7 @@ public class AncientAltarListener implements Listener {
@EventHandler
public void onPickup(PlayerPickupItemEvent 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("§5§dALTAR §3Probe - §e")) {
e.setCancelled(true);
e.getItem().remove();
}
}
@EventHandler
public void onMinecraftPickup(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("§5§dALTAR §3Probe - §e")) {
else if (!e.getItem().hasMetadata("no_pickup") && e.getItem().getItemStack().hasItemMeta() && e.getItem().getItemStack().getItemMeta().hasDisplayName() && e.getItem().getItemStack().getItemMeta().getDisplayName().startsWith("§5§dALTAR §3Probe - §e")) {
e.setCancelled(true);
e.getItem().remove();
}

View File

@ -3,6 +3,29 @@ package me.mrCookieSlime.Slimefun.listeners;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Skull;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.Player;
import org.bukkit.entity.Wither;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.inventory.CraftItemEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemConsumeEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib;
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Variable;
import me.mrCookieSlime.CSCoreLibPlugin.events.ItemUseEvent;
@ -27,29 +50,6 @@ import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
import me.mrCookieSlime.Slimefun.api.inventory.UniversalBlockMenu;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Skull;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.Player;
import org.bukkit.entity.Wither;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.inventory.CraftItemEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemConsumeEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class ItemListener implements Listener {
public ItemListener(SlimefunStartup plugin) {
@ -290,7 +290,9 @@ public class ItemListener implements Listener {
@EventHandler
public void onAnvil(InventoryClickEvent e) {
if (e.getRawSlot() == 2 && e.getWhoClicked() instanceof Player && e.getInventory().getType() == InventoryType.ANVIL) {
if (SlimefunItem.getByItem(e.getInventory().getContents()[0]) != null && !SlimefunItem.isDisabled(e.getInventory().getContents()[0]) && e.getInventory().getContents()[0].getType() != Material.ELYTRA) {
if (SlimefunManager.isItemSimiliar(e.getInventory().getContents()[0], SlimefunItems.ELYTRA, true)) return;
if (SlimefunItem.getByItem(e.getInventory().getContents()[0]) != null && !SlimefunItem.isDisabled(e.getInventory().getContents()[0])) {
e.setCancelled(true);
Messages.local.sendTranslation((Player) e.getWhoClicked(), "anvil.not-working", true);
}