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:
commit
06e1424db1
@ -1,124 +1,149 @@
|
|||||||
package me.mrCookieSlime.CSCoreLibSetup;
|
package me.mrCookieSlime.CSCoreLibSetup;
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.net.MalformedURLException;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URLConnection;
|
import java.net.URL;
|
||||||
|
import java.net.URLConnection;
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
import org.json.simple.JSONArray;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.json.simple.JSONObject;
|
import org.json.simple.JSONArray;
|
||||||
import org.json.simple.JSONValue;
|
import org.json.simple.JSONObject;
|
||||||
|
import org.json.simple.JSONValue;
|
||||||
public class CSCoreLibLoader {
|
|
||||||
|
public class CSCoreLibLoader {
|
||||||
Plugin plugin;
|
|
||||||
URL url;
|
Plugin plugin;
|
||||||
URL download;
|
URL url;
|
||||||
File file;
|
URL download;
|
||||||
|
File file;
|
||||||
public CSCoreLibLoader(Plugin plugin) {
|
|
||||||
this.plugin = plugin;
|
public CSCoreLibLoader(Plugin plugin) {
|
||||||
try {
|
this.plugin = plugin;
|
||||||
this.url = new URL("https://api.curseforge.com/servermods/files?projectIds=88802");
|
try {
|
||||||
} catch (MalformedURLException e) {
|
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;
|
public boolean load() {
|
||||||
else {
|
if (plugin.getServer().getPluginManager().isPluginEnabled("CS-CoreLib")) return true;
|
||||||
System.err.println(" ");
|
else {
|
||||||
System.err.println("#################### - FATAL ERROR - ####################");
|
System.err.println(" ");
|
||||||
System.err.println(" ");
|
System.err.println("#################### - FATAL ERROR - ####################");
|
||||||
System.err.println(plugin.getName() + " could not be properly installed!");
|
System.err.println(" ");
|
||||||
System.err.println("It appears that you have not installed CS-CoreLib");
|
System.err.println(plugin.getName() + " could not be properly installed!");
|
||||||
System.err.println("And because of that, CS-CoreLib is now going to be");
|
System.err.println("It appears that you have not installed CS-CoreLib");
|
||||||
System.err.println("downloaded and installed.");
|
System.err.println("And because of that, CS-CoreLib is now going to be");
|
||||||
System.err.println("But for the time being " + plugin.getName() + " will remain disabled");
|
System.err.println("downloaded and installed.");
|
||||||
System.err.println("After the installation process has finished,");
|
System.err.println("But for the time being " + plugin.getName() + " will remain disabled");
|
||||||
System.out.println("you will be asked to restart your Server.");
|
System.err.println("After the installation process has finished,");
|
||||||
System.err.println("- mrCookieSlime");
|
System.out.println("you will be asked to restart your Server.");
|
||||||
System.err.println(" ");
|
System.err.println("- mrCookieSlime");
|
||||||
System.err.println("#################### - FATAL ERROR - ####################");
|
System.err.println(" ");
|
||||||
System.err.println(" ");
|
System.err.println("#################### - FATAL ERROR - ####################");
|
||||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
System.err.println(" ");
|
||||||
|
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||||
@Override
|
|
||||||
public void run() {
|
@Override
|
||||||
if (connect()) install();
|
public void run() {
|
||||||
}
|
if (connect()) install();
|
||||||
}, 10L);
|
}
|
||||||
return false;
|
}, 10L);
|
||||||
}
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private boolean connect() {
|
|
||||||
try {
|
private boolean connect() {
|
||||||
final URLConnection connection = this.url.openConnection();
|
try {
|
||||||
connection.setConnectTimeout(5000);
|
final URLConnection connection = this.url.openConnection();
|
||||||
connection.addRequestProperty("User-Agent", "CS-CoreLib Loader (by mrCookieSlime)");
|
connection.setConnectTimeout(5000);
|
||||||
connection.setDoOutput(true);
|
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());
|
final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||||
download = new URL((String) ((JSONObject) array.get(array.size() - 1)).get("downloadUrl"));
|
final JSONArray array = (JSONArray) JSONValue.parse(reader.readLine());
|
||||||
file = new File("plugins/" + (String) ((JSONObject) array.get(array.size() - 1)).get("name") + ".jar");
|
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) {
|
return true;
|
||||||
System.err.println(" ");
|
} catch (IOException e) {
|
||||||
System.err.println("#################### - FATAL ERROR - ####################");
|
System.err.println(" ");
|
||||||
System.err.println(" ");
|
System.err.println("#################### - FATAL ERROR - ####################");
|
||||||
System.err.println("Could not connect to BukkitDev, is it down?");
|
System.err.println(" ");
|
||||||
System.err.println(" ");
|
System.err.println("Could not connect to BukkitDev, is it down?");
|
||||||
System.err.println("#################### - FATAL ERROR - ####################");
|
System.err.println(" ");
|
||||||
System.err.println(" ");
|
System.err.println("#################### - FATAL ERROR - ####################");
|
||||||
return false;
|
System.err.println(" ");
|
||||||
}
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private void install() {
|
|
||||||
BufferedInputStream input = null;
|
private URL traceURL(String location) throws IOException {
|
||||||
FileOutputStream output = null;
|
HttpURLConnection connection = null;
|
||||||
try {
|
|
||||||
input = new BufferedInputStream(download.openStream());
|
while (true) {
|
||||||
output = new FileOutputStream(file);
|
URL url = new URL(location);
|
||||||
|
connection = (HttpURLConnection) url.openConnection();
|
||||||
final byte[] data = new byte[1024];
|
|
||||||
int read;
|
connection.setInstanceFollowRedirects(false);
|
||||||
while ((read = input.read(data, 0, 1024)) != -1) {
|
connection.setConnectTimeout(5000);
|
||||||
output.write(data, 0, read);
|
connection.addRequestProperty("User-Agent", "Auto Updater (by mrCookieSlime)");
|
||||||
}
|
|
||||||
} catch (Exception ex) {
|
switch (connection.getResponseCode()) {
|
||||||
System.err.println(" ");
|
case HttpURLConnection.HTTP_MOVED_PERM:
|
||||||
System.err.println("#################### - FATAL ERROR - ####################");
|
case HttpURLConnection.HTTP_MOVED_TEMP:
|
||||||
System.err.println(" ");
|
String loc = connection.getHeaderField("Location");
|
||||||
System.err.println("Could not download CS-CoreLib");
|
location = new URL(new URL(location), loc).toExternalForm();
|
||||||
System.err.println(" ");
|
continue;
|
||||||
System.err.println("#################### - FATAL ERROR - ####################");
|
}
|
||||||
System.err.println(" ");
|
break;
|
||||||
} finally {
|
}
|
||||||
try {
|
|
||||||
if (input != null) input.close();
|
return connection.getURL();
|
||||||
if (output != null) output.close();
|
}
|
||||||
System.err.println(" ");
|
|
||||||
System.err.println("#################### - WARNING - ####################");
|
private void install() {
|
||||||
System.err.println(" ");
|
BufferedInputStream input = null;
|
||||||
System.err.println("Please restart your Server to finish the Installation");
|
FileOutputStream output = null;
|
||||||
System.err.println("of " + plugin.getName() + " and CS-CoreLib");
|
try {
|
||||||
System.err.println(" ");
|
input = new BufferedInputStream(download.openStream());
|
||||||
System.err.println("#################### - WARNING - ####################");
|
output = new FileOutputStream(file);
|
||||||
System.err.println(" ");
|
|
||||||
} catch (IOException e) {
|
final byte[] data = new byte[1024];
|
||||||
e.printStackTrace();
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines;
|
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.ChestMenu.MenuClickHandler;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
|
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
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.SlimefunBlockHandler;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.UnregisterReason;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.UnregisterReason;
|
||||||
|
import me.mrCookieSlime.Slimefun.Setup.Messages;
|
||||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||||
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
|
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
|
||||||
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
|
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
|
||||||
import me.mrCookieSlime.Slimefun.api.item_transport.CargoNet;
|
import me.mrCookieSlime.Slimefun.api.item_transport.CargoNet;
|
||||||
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
|
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 {
|
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};
|
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) {
|
public AdvancedCargoOutputNode(Category category, ItemStack item, String name, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) {
|
||||||
super(category, item, name, recipeType, recipe, recipeOutput);
|
super(category, item, name, recipeType, recipe, recipeOutput);
|
||||||
|
|
||||||
new BlockMenuPreset(name, "§cOutput Node") {
|
new BlockMenuPreset(name, "§cOutput Node") {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init() {
|
public void init() {
|
||||||
@ -41,7 +43,7 @@ public class AdvancedCargoOutputNode extends SlimefunItem {
|
|||||||
public void newInstance(final BlockMenu menu, final Block b) {
|
public void newInstance(final BlockMenu menu, final Block b) {
|
||||||
try {
|
try {
|
||||||
if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getBlockInfo(b, "filter-type") == null || BlockStorage.getBlockInfo(b, "filter-type").equals("whitelist")) {
|
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() {
|
menu.addMenuClickHandler(15, new MenuClickHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -53,7 +55,7 @@ public class AdvancedCargoOutputNode extends SlimefunItem {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
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() {
|
menu.addMenuClickHandler(15, new MenuClickHandler() {
|
||||||
|
|
||||||
@Override
|
@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")) {
|
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() {
|
menu.addMenuClickHandler(16, new MenuClickHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -78,7 +80,7 @@ public class AdvancedCargoOutputNode extends SlimefunItem {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
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() {
|
menu.addMenuClickHandler(16, new MenuClickHandler() {
|
||||||
|
|
||||||
@Override
|
@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")) {
|
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() {
|
menu.addMenuClickHandler(25, new MenuClickHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -103,7 +105,7 @@ public class AdvancedCargoOutputNode extends SlimefunItem {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
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() {
|
menu.addMenuClickHandler(25, new MenuClickHandler() {
|
||||||
|
|
||||||
@Override
|
@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() {
|
menu.addMenuClickHandler(41, new MenuClickHandler() {
|
||||||
|
|
||||||
@Override
|
@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"))));
|
int channel = ((!BlockStorage.hasBlockInfo(b) || BlockStorage.getBlockInfo(b, "frequency") == null) ? 0: (Integer.parseInt(BlockStorage.getBlockInfo(b, "frequency"))));
|
||||||
|
|
||||||
if (channel == 16) {
|
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() {
|
menu.addMenuClickHandler(42, new MenuClickHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -144,7 +146,7 @@ public class AdvancedCargoOutputNode extends SlimefunItem {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
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() {
|
menu.addMenuClickHandler(42, new MenuClickHandler() {
|
||||||
|
|
||||||
@Override
|
@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() {
|
menu.addMenuClickHandler(43, new MenuClickHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -181,7 +183,11 @@ public class AdvancedCargoOutputNode extends SlimefunItem {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canOpen(Block b, Player p) {
|
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
|
@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() {
|
new MenuClickHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines;
|
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.ChestMenu.MenuClickHandler;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
|
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
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.inventory.BlockMenuPreset;
|
||||||
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
|
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 {
|
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};
|
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) {
|
public CargoCraftingNode(Category category, ItemStack item, String name, RecipeType recipeType, ItemStack[] recipe) {
|
||||||
super(category, item, name, recipeType, recipe);
|
super(category, item, name, recipeType, recipe);
|
||||||
|
|
||||||
new BlockMenuPreset(name, "§3Input Node") {
|
new BlockMenuPreset(name, "§3Input Node") {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init() {
|
public void init() {
|
||||||
@ -39,7 +40,7 @@ public class CargoCraftingNode extends SlimefunItem {
|
|||||||
@Override
|
@Override
|
||||||
public void newInstance(final BlockMenu menu, final Block b) {
|
public void newInstance(final BlockMenu menu, final Block b) {
|
||||||
try {
|
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() {
|
menu.addMenuClickHandler(41, new MenuClickHandler() {
|
||||||
|
|
||||||
@Override
|
@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() {
|
menu.addMenuClickHandler(42, new MenuClickHandler() {
|
||||||
|
|
||||||
@Override
|
@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() {
|
menu.addMenuClickHandler(43, new MenuClickHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -81,7 +82,7 @@ public class CargoCraftingNode extends SlimefunItem {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canOpen(Block b, Player p) {
|
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) {
|
if (!open) {
|
||||||
Messages.local.sendTranslation(p, "inventory.no-access", true);
|
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() {
|
new MenuClickHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines;
|
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.ChestMenu.MenuClickHandler;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
|
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
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.CargoNet;
|
||||||
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
|
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 {
|
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};
|
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) {
|
public CargoInputNode(Category category, ItemStack item, String name, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) {
|
||||||
super(category, item, name, recipeType, recipe, recipeOutput);
|
super(category, item, name, recipeType, recipe, recipeOutput);
|
||||||
|
|
||||||
new BlockMenuPreset(name, "§3Input Node") {
|
new BlockMenuPreset(name, "§3Input Node") {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init() {
|
public void init() {
|
||||||
@ -42,7 +43,7 @@ public class CargoInputNode extends SlimefunItem {
|
|||||||
public void newInstance(final BlockMenu menu, final Block b) {
|
public void newInstance(final BlockMenu menu, final Block b) {
|
||||||
try {
|
try {
|
||||||
if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getBlockInfo(b, "filter-type") == null || BlockStorage.getBlockInfo(b, "filter-type").equals("whitelist")) {
|
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() {
|
menu.addMenuClickHandler(15, new MenuClickHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -54,7 +55,7 @@ public class CargoInputNode extends SlimefunItem {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
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() {
|
menu.addMenuClickHandler(15, new MenuClickHandler() {
|
||||||
|
|
||||||
@Override
|
@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")) {
|
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() {
|
menu.addMenuClickHandler(16, new MenuClickHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -79,7 +80,7 @@ public class CargoInputNode extends SlimefunItem {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
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() {
|
menu.addMenuClickHandler(16, new MenuClickHandler() {
|
||||||
|
|
||||||
@Override
|
@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")) {
|
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() {
|
menu.addMenuClickHandler(24, new MenuClickHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -104,7 +105,7 @@ public class CargoInputNode extends SlimefunItem {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
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() {
|
menu.addMenuClickHandler(24, new MenuClickHandler() {
|
||||||
|
|
||||||
@Override
|
@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")) {
|
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() {
|
menu.addMenuClickHandler(25, new MenuClickHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -129,7 +130,7 @@ public class CargoInputNode extends SlimefunItem {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
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() {
|
menu.addMenuClickHandler(25, new MenuClickHandler() {
|
||||||
|
|
||||||
@Override
|
@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() {
|
menu.addMenuClickHandler(41, new MenuClickHandler() {
|
||||||
|
|
||||||
@Override
|
@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"))));
|
int channel = ((!BlockStorage.hasBlockInfo(b) || BlockStorage.getBlockInfo(b, "frequency") == null) ? 0: (Integer.parseInt(BlockStorage.getBlockInfo(b, "frequency"))));
|
||||||
|
|
||||||
if (channel == 16) {
|
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() {
|
menu.addMenuClickHandler(42, new MenuClickHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -170,7 +171,7 @@ public class CargoInputNode extends SlimefunItem {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
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() {
|
menu.addMenuClickHandler(42, new MenuClickHandler() {
|
||||||
|
|
||||||
@Override
|
@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() {
|
menu.addMenuClickHandler(43, new MenuClickHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -207,7 +208,7 @@ public class CargoInputNode extends SlimefunItem {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canOpen(Block b, Player p) {
|
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) {
|
if (!open) {
|
||||||
Messages.local.sendTranslation(p, "inventory.no-access", true);
|
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() {
|
new MenuClickHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines;
|
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.ChestMenu.MenuClickHandler;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
|
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
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.CargoNet;
|
||||||
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
|
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 {
|
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};
|
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) {
|
public CargoOutputNode(Category category, ItemStack item, String name, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) {
|
||||||
super(category, item, name, recipeType, recipe, recipeOutput);
|
super(category, item, name, recipeType, recipe, recipeOutput);
|
||||||
|
|
||||||
new BlockMenuPreset(name, "§6Output Node") {
|
new BlockMenuPreset(name, "§6Output Node") {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init() {
|
public void init() {
|
||||||
@ -42,7 +43,7 @@ public class CargoOutputNode extends SlimefunItem {
|
|||||||
public void newInstance(final BlockMenu menu, final Block b) {
|
public void newInstance(final BlockMenu menu, final Block b) {
|
||||||
try {
|
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() {
|
menu.addMenuClickHandler(12, new MenuClickHandler() {
|
||||||
|
|
||||||
@Override
|
@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"))));
|
int channel = ((!BlockStorage.hasBlockInfo(b) || BlockStorage.getBlockInfo(b, "frequency") == null) ? 0: (Integer.parseInt(BlockStorage.getBlockInfo(b, "frequency"))));
|
||||||
|
|
||||||
if (channel == 16) {
|
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() {
|
menu.addMenuClickHandler(13, new MenuClickHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -71,7 +72,7 @@ public class CargoOutputNode extends SlimefunItem {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
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() {
|
menu.addMenuClickHandler(13, new MenuClickHandler() {
|
||||||
|
|
||||||
@Override
|
@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() {
|
menu.addMenuClickHandler(14, new MenuClickHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -108,7 +109,7 @@ public class CargoOutputNode extends SlimefunItem {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canOpen(Block b, Player p) {
|
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) {
|
if (!open) {
|
||||||
Messages.local.sendTranslation(p, "inventory.no-access", true);
|
Messages.local.sendTranslation(p, "inventory.no-access", true);
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,6 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
import org.bukkit.event.inventory.InventoryPickupItemEvent;
|
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@ -37,14 +36,14 @@ import org.bukkit.metadata.FixedMetadataValue;
|
|||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
public class AncientAltarListener implements Listener {
|
public class AncientAltarListener implements Listener {
|
||||||
|
|
||||||
public AncientAltarListener(SlimefunStartup plugin) {
|
public AncientAltarListener(SlimefunStartup plugin) {
|
||||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Block> altars = new ArrayList<Block>();
|
List<Block> altars = new ArrayList<Block>();
|
||||||
Set<UUID> removed_items = new HashSet<UUID>();
|
Set<UUID> removed_items = new HashSet<UUID>();
|
||||||
|
|
||||||
@EventHandler(priority=EventPriority.HIGH)
|
@EventHandler(priority=EventPriority.HIGH)
|
||||||
public void onInteract(PlayerInteractEvent e) {
|
public void onInteract(PlayerInteractEvent e) {
|
||||||
if (e.getAction() != Action.RIGHT_CLICK_BLOCK) return;
|
if (e.getAction() != Action.RIGHT_CLICK_BLOCK) return;
|
||||||
@ -60,9 +59,9 @@ public class AncientAltarListener implements Listener {
|
|||||||
else if (!removed_items.contains(stack.getUniqueId())) {
|
else if (!removed_items.contains(stack.getUniqueId())) {
|
||||||
final UUID uuid = stack.getUniqueId();
|
final UUID uuid = stack.getUniqueId();
|
||||||
removed_items.add(uuid);
|
removed_items.add(uuid);
|
||||||
|
|
||||||
SlimefunStartup.instance.getServer().getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, new Runnable() {
|
SlimefunStartup.instance.getServer().getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
removed_items.remove(uuid);
|
removed_items.remove(uuid);
|
||||||
@ -77,10 +76,10 @@ public class AncientAltarListener implements Listener {
|
|||||||
}
|
}
|
||||||
else if (item.getName().equals("ANCIENT_ALTAR")) {
|
else if (item.getName().equals("ANCIENT_ALTAR")) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
|
|
||||||
ItemStack catalyst = e.getPlayer().getInventory().getItemInMainHand();
|
ItemStack catalyst = new CustomItem(e.getPlayer().getInventory().getItemInMainHand(), 1);
|
||||||
List<Block> pedestals = Pedestals.getPedestals(b);
|
List<Block> pedestals = Pedestals.getPedestals(b);
|
||||||
|
|
||||||
if (!altars.contains(e.getClickedBlock())) {
|
if (!altars.contains(e.getClickedBlock())) {
|
||||||
altars.add(e.getClickedBlock());
|
altars.add(e.getClickedBlock());
|
||||||
if (pedestals.size() == 8) {
|
if (pedestals.size() == 8) {
|
||||||
@ -90,7 +89,7 @@ public class AncientAltarListener implements Listener {
|
|||||||
Item stack = findItem(pedestal);
|
Item stack = findItem(pedestal);
|
||||||
if (stack != null) input.add(fixItemStack(stack.getItemStack(), stack.getCustomName()));
|
if (stack != null) input.add(fixItemStack(stack.getItemStack(), stack.getCustomName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack result = Pedestals.getRecipeOutput(catalyst, input);
|
ItemStack result = Pedestals.getRecipeOutput(catalyst, input);
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
List<ItemStack> consumed = new ArrayList<ItemStack>();
|
List<ItemStack> consumed = new ArrayList<ItemStack>();
|
||||||
@ -116,7 +115,7 @@ public class AncientAltarListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ItemStack fixItemStack(ItemStack itemStack, String customName) {
|
private ItemStack fixItemStack(ItemStack itemStack, String customName) {
|
||||||
ItemStack stack = itemStack.clone();
|
ItemStack stack = itemStack.clone();
|
||||||
if (customName.equals(StringUtils.formatItemName(itemStack.getData().toItemStack(1), false))) {
|
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)) {
|
if (stack != null && !stack.getType().equals(Material.AIR)) {
|
||||||
PlayerInventory.consumeItemInHand(p);
|
PlayerInventory.consumeItemInHand(p);
|
||||||
String nametag = StringUtils.formatItemName(stack, false);
|
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.setVelocity(new Vector(0, 0.1, 0));
|
||||||
entity.setMetadata("no_pickup", new FixedMetadataValue(SlimefunStartup.instance, "altar_item"));
|
entity.setMetadata("no_pickup", new FixedMetadataValue(SlimefunStartup.instance, "altar_item"));
|
||||||
entity.setCustomNameVisible(true);
|
entity.setCustomNameVisible(true);
|
||||||
@ -158,16 +157,7 @@ public class AncientAltarListener implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPickup(PlayerPickupItemEvent e) {
|
public void onPickup(PlayerPickupItemEvent e) {
|
||||||
if (e.getItem().hasMetadata("no_pickup")) e.setCancelled(true);
|
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@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")) {
|
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
e.getItem().remove();
|
e.getItem().remove();
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,29 @@ package me.mrCookieSlime.Slimefun.listeners;
|
|||||||
|
|
||||||
import java.util.List;
|
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.CSCoreLib;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Variable;
|
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Variable;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.events.ItemUseEvent;
|
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.BlockMenuPreset;
|
||||||
import me.mrCookieSlime.Slimefun.api.inventory.UniversalBlockMenu;
|
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 class ItemListener implements Listener {
|
||||||
|
|
||||||
public ItemListener(SlimefunStartup plugin) {
|
public ItemListener(SlimefunStartup plugin) {
|
||||||
@ -290,7 +290,9 @@ public class ItemListener implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onAnvil(InventoryClickEvent e) {
|
public void onAnvil(InventoryClickEvent e) {
|
||||||
if (e.getRawSlot() == 2 && e.getWhoClicked() instanceof Player && e.getInventory().getType() == InventoryType.ANVIL) {
|
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);
|
e.setCancelled(true);
|
||||||
Messages.local.sendTranslation((Player) e.getWhoClicked(), "anvil.not-working", true);
|
Messages.local.sendTranslation((Player) e.getWhoClicked(), "anvil.not-working", true);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user