mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
commit
ab14aa7a48
@ -8,6 +8,7 @@ options:
|
|||||||
auto-save-delay-in-minutes: 10
|
auto-save-delay-in-minutes: 10
|
||||||
show-vanilla-recipes-in-guide: true
|
show-vanilla-recipes-in-guide: true
|
||||||
allow-free-creative-research: true
|
allow-free-creative-research: true
|
||||||
|
emerald-enchantment-limit: 2
|
||||||
guide:
|
guide:
|
||||||
default-view-book: false
|
default-view-book: false
|
||||||
URID:
|
URID:
|
||||||
|
@ -29,6 +29,7 @@ import org.bukkit.inventory.meta.ItemMeta;
|
|||||||
import org.bukkit.material.MaterialData;
|
import org.bukkit.material.MaterialData;
|
||||||
|
|
||||||
public class AutoEnchanter extends AContainer {
|
public class AutoEnchanter extends AContainer {
|
||||||
|
public static int max_emerald_enchantments = 2;
|
||||||
|
|
||||||
public AutoEnchanter(Category category, ItemStack item, String name, RecipeType recipeType, ItemStack[] recipe) {
|
public AutoEnchanter(Category category, ItemStack item, String name, RecipeType recipeType, ItemStack[] recipe) {
|
||||||
super(category, item, name, recipeType, recipe);
|
super(category, item, name, recipeType, recipe);
|
||||||
@ -51,7 +52,7 @@ public class AutoEnchanter extends AContainer {
|
|||||||
public int getEnergyConsumption() {
|
public int getEnergyConsumption() {
|
||||||
return 9;
|
return 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
protected void tick(Block b) {
|
protected void tick(Block b) {
|
||||||
@ -68,9 +69,9 @@ public class AutoEnchanter extends AContainer {
|
|||||||
lore.add(MachineHelper.getTimeLeft(timeleft / 2));
|
lore.add(MachineHelper.getTimeLeft(timeleft / 2));
|
||||||
im.setLore(lore);
|
im.setLore(lore);
|
||||||
item.setItemMeta(im);
|
item.setItemMeta(im);
|
||||||
|
|
||||||
BlockStorage.getInventory(b).replaceExistingItem(22, item);
|
BlockStorage.getInventory(b).replaceExistingItem(22, item);
|
||||||
|
|
||||||
if (ChargableBlock.isChargable(b)) {
|
if (ChargableBlock.isChargable(b)) {
|
||||||
if (ChargableBlock.getCharge(b) < getEnergyConsumption()) return;
|
if (ChargableBlock.getCharge(b) < getEnergyConsumption()) return;
|
||||||
ChargableBlock.addCharge(b, -getEnergyConsumption());
|
ChargableBlock.addCharge(b, -getEnergyConsumption());
|
||||||
@ -81,7 +82,7 @@ public class AutoEnchanter extends AContainer {
|
|||||||
else {
|
else {
|
||||||
BlockStorage.getInventory(b).replaceExistingItem(22, new CustomItem(new MaterialData(Material.STAINED_GLASS_PANE, (byte) 15), " "));
|
BlockStorage.getInventory(b).replaceExistingItem(22, new CustomItem(new MaterialData(Material.STAINED_GLASS_PANE, (byte) 15), " "));
|
||||||
pushItems(b, processing.get(b).getOutput());
|
pushItems(b, processing.get(b).getOutput());
|
||||||
|
|
||||||
progress.remove(b);
|
progress.remove(b);
|
||||||
processing.remove(b);
|
processing.remove(b);
|
||||||
}
|
}
|
||||||
@ -96,6 +97,7 @@ public class AutoEnchanter extends AContainer {
|
|||||||
Map<Enchantment, Integer> enchantments = new HashMap<Enchantment, Integer>();
|
Map<Enchantment, Integer> enchantments = new HashMap<Enchantment, Integer>();
|
||||||
Set<ItemEnchantment> enchantments2 = new HashSet<ItemEnchantment>();
|
Set<ItemEnchantment> enchantments2 = new HashSet<ItemEnchantment>();
|
||||||
int amount = 0;
|
int amount = 0;
|
||||||
|
int special_amount = 0;
|
||||||
EnchantmentStorageMeta meta = (EnchantmentStorageMeta) item.getItemMeta();
|
EnchantmentStorageMeta meta = (EnchantmentStorageMeta) item.getItemMeta();
|
||||||
for (Map.Entry<Enchantment, Integer> e: meta.getStoredEnchants().entrySet()) {
|
for (Map.Entry<Enchantment, Integer> e: meta.getStoredEnchants().entrySet()) {
|
||||||
if (e.getKey().canEnchantItem(target)) {
|
if (e.getKey().canEnchantItem(target)) {
|
||||||
@ -107,12 +109,13 @@ public class AutoEnchanter extends AContainer {
|
|||||||
for (ItemEnchantment enchantment: EmeraldEnchants.getInstance().getRegistry().getEnchantments(item)) {
|
for (ItemEnchantment enchantment: EmeraldEnchants.getInstance().getRegistry().getEnchantments(item)) {
|
||||||
if (EmeraldEnchants.getInstance().getRegistry().isApplicable(target, enchantment.getEnchantment()) && EmeraldEnchants.getInstance().getRegistry().getEnchantmentLevel(target, enchantment.getEnchantment().getName()) < enchantment.getLevel()) {
|
if (EmeraldEnchants.getInstance().getRegistry().isApplicable(target, enchantment.getEnchantment()) && EmeraldEnchants.getInstance().getRegistry().getEnchantmentLevel(target, enchantment.getEnchantment().getName()) < enchantment.getLevel()) {
|
||||||
amount++;
|
amount++;
|
||||||
|
special_amount++;
|
||||||
enchantments2.add(enchantment);
|
enchantments2.add(enchantment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
special_amount+=EmeraldEnchants.getInstance().getRegistry().getEnchantments(target).size();
|
||||||
}
|
}
|
||||||
|
if (amount > 0 && special_amount <= max_emerald_enchantments) {
|
||||||
if (amount > 0) {
|
|
||||||
ItemStack newItem = target.clone();
|
ItemStack newItem = target.clone();
|
||||||
for (Map.Entry<Enchantment, Integer> e: enchantments.entrySet()) {
|
for (Map.Entry<Enchantment, Integer> e: enchantments.entrySet()) {
|
||||||
newItem.addUnsafeEnchantment(e.getKey(), e.getValue());
|
newItem.addUnsafeEnchantment(e.getKey(), e.getValue());
|
||||||
@ -125,7 +128,7 @@ public class AutoEnchanter extends AContainer {
|
|||||||
break slots;
|
break slots;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (r != null) {
|
if (r != null) {
|
||||||
if (!fits(b, r.getOutput())) return;
|
if (!fits(b, r.getOutput())) return;
|
||||||
for (int slot: getInputSlots()) {
|
for (int slot: getInputSlots()) {
|
||||||
|
@ -13,11 +13,7 @@ import org.bukkit.Effect;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.*;
|
||||||
import org.bukkit.block.BlockFace;
|
|
||||||
import org.bukkit.block.Chest;
|
|
||||||
import org.bukkit.block.CreatureSpawner;
|
|
||||||
import org.bukkit.block.Dispenser;
|
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.ArmorStand;
|
import org.bukkit.entity.ArmorStand;
|
||||||
import org.bukkit.entity.Arrow;
|
import org.bukkit.entity.Arrow;
|
||||||
@ -2008,6 +2004,7 @@ public class SlimefunSetup {
|
|||||||
Block b = e.getBlock().getRelative(x, y, z);
|
Block b = e.getBlock().getRelative(x, y, z);
|
||||||
if (b.getType() != Material.AIR && !StringUtils.equals(b.getType().toString(), explosiveblacklist)) {
|
if (b.getType() != Material.AIR && !StringUtils.equals(b.getType().toString(), explosiveblacklist)) {
|
||||||
if (CSCoreLib.getLib().getProtectionManager().canBuild(e.getPlayer().getUniqueId(), b)) {
|
if (CSCoreLib.getLib().getProtectionManager().canBuild(e.getPlayer().getUniqueId(), b)) {
|
||||||
|
if (SlimefunStartup.instance.isCoreProtectInstalled()) SlimefunStartup.instance.getCoreProtectAPI().logRemoval(e.getPlayer().getName(), b.getLocation(), b.getType(), b.getData());
|
||||||
b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType());
|
b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType());
|
||||||
SlimefunItem sfItem = BlockStorage.check(b);
|
SlimefunItem sfItem = BlockStorage.check(b);
|
||||||
boolean allow = true;
|
boolean allow = true;
|
||||||
@ -2022,6 +2019,9 @@ public class SlimefunSetup {
|
|||||||
else if (b.getType().equals(Material.SKULL)) {
|
else if (b.getType().equals(Material.SKULL)) {
|
||||||
b.breakNaturally();
|
b.breakNaturally();
|
||||||
}
|
}
|
||||||
|
else if (b.getType().name().endsWith("_SHULKER_BOX")) {
|
||||||
|
b.breakNaturally();
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
for (ItemStack drop: b.getDrops()) {
|
for (ItemStack drop: b.getDrops()) {
|
||||||
b.getWorld().dropItemNaturally(b.getLocation(), (b.getType().toString().endsWith("_ORE") && !b.getType().equals(Material.IRON_ORE) && !b.getType().equals(Material.GOLD_ORE)) ? new CustomItem(drop, fortune): drop);
|
b.getWorld().dropItemNaturally(b.getLocation(), (b.getType().toString().endsWith("_ORE") && !b.getType().equals(Material.IRON_ORE) && !b.getType().equals(Material.GOLD_ORE)) ? new CustomItem(drop, fortune): drop);
|
||||||
|
@ -15,6 +15,9 @@ import java.util.Map;
|
|||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipOutputStream;
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.AutoEnchanter;
|
||||||
|
import net.coreprotect.CoreProtect;
|
||||||
|
import net.coreprotect.CoreProtectAPI;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -99,8 +102,11 @@ public class SlimefunStartup extends JavaPlugin {
|
|||||||
|
|
||||||
public static TickerTask ticker;
|
public static TickerTask ticker;
|
||||||
|
|
||||||
|
private CoreProtectAPI coreProtectAPI;
|
||||||
|
|
||||||
private boolean clearlag = false;
|
private boolean clearlag = false;
|
||||||
private boolean exoticGarden = false;
|
private boolean exoticGarden = false;
|
||||||
|
private boolean coreProtect = false;
|
||||||
|
|
||||||
// Supported Versions of Minecraft
|
// Supported Versions of Minecraft
|
||||||
final String[] supported = {"v1_9_", "v1_10_", "v1_11_", "PluginBukkitBridge"};
|
final String[] supported = {"v1_9_", "v1_10_", "v1_11_", "PluginBukkitBridge"};
|
||||||
@ -375,6 +381,8 @@ public class SlimefunStartup extends JavaPlugin {
|
|||||||
|
|
||||||
clearlag = getServer().getPluginManager().isPluginEnabled("ClearLag");
|
clearlag = getServer().getPluginManager().isPluginEnabled("ClearLag");
|
||||||
|
|
||||||
|
coreProtect = getServer().getPluginManager().isPluginEnabled("CoreProtect");
|
||||||
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new BukkitRunnable() {
|
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -384,7 +392,13 @@ public class SlimefunStartup extends JavaPlugin {
|
|||||||
|
|
||||||
if (clearlag) new ClearLaggIntegration(this);
|
if (clearlag) new ClearLaggIntegration(this);
|
||||||
|
|
||||||
|
if (coreProtect) coreProtectAPI = ((CoreProtect)getServer().getPluginManager().getPlugin("CoreProtect")).getAPI();
|
||||||
|
|
||||||
|
|
||||||
SlimefunGuide.creative_research = config.getBoolean("options.allow-free-creative-research");
|
SlimefunGuide.creative_research = config.getBoolean("options.allow-free-creative-research");
|
||||||
|
|
||||||
|
AutoEnchanter.max_emerald_enchantments = config.getInt("options.emerald-enchantment-limit");
|
||||||
|
|
||||||
// Do not show /sf elevator command in our Log, it could get quite spammy
|
// Do not show /sf elevator command in our Log, it could get quite spammy
|
||||||
CSCoreLib.getLib().filterLog("([A-Za-z0-9_]{3,16}) issued server command: /sf elevator (.{0,})");
|
CSCoreLib.getLib().filterLog("([A-Za-z0-9_]{3,16}) issued server command: /sf elevator (.{0,})");
|
||||||
}
|
}
|
||||||
@ -594,4 +608,12 @@ public class SlimefunStartup extends JavaPlugin {
|
|||||||
public boolean isExoticGardenInstalled () {
|
public boolean isExoticGardenInstalled () {
|
||||||
return exoticGarden;
|
return exoticGarden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isCoreProtectInstalled() {
|
||||||
|
return coreProtect;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CoreProtectAPI getCoreProtectAPI() {
|
||||||
|
return coreProtectAPI;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -185,7 +185,7 @@ public class CargoManager {
|
|||||||
|
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
|
//Whitelist or blacklist slots
|
||||||
private static int[] slots = new int[] {19, 20, 21, 28, 29, 30, 37, 38, 39};
|
private static int[] slots = new int[] {19, 20, 21, 28, 29, 30, 37, 38, 39};
|
||||||
|
|
||||||
public static boolean matchesFilter(Block block, ItemStack item, int index) {
|
public static boolean matchesFilter(Block block, ItemStack item, int index) {
|
||||||
|
@ -55,7 +55,8 @@ public class CargoNet {
|
|||||||
public static Set<ItemRequest> requests = new HashSet<ItemRequest>();
|
public static Set<ItemRequest> requests = new HashSet<ItemRequest>();
|
||||||
|
|
||||||
private static int[] slots = new int[] {19, 20, 21, 28, 29, 30, 37, 38, 39};
|
private static int[] slots = new int[] {19, 20, 21, 28, 29, 30, 37, 38, 39};
|
||||||
|
|
||||||
|
//Chest Terminal Stuff
|
||||||
private static final ChestTerminalSorter sorter = new ChestTerminalSorter();
|
private static final ChestTerminalSorter sorter = new ChestTerminalSorter();
|
||||||
public static final int[] terminal_slots = new int[] {0, 1, 2, 3, 4, 5, 6, 9, 10, 11, 12, 13, 14, 15, 18, 19, 20, 21, 22, 23, 24, 27, 28, 29, 30, 31, 32, 33, 36, 37, 38, 39, 40, 41, 42};
|
public static final int[] terminal_slots = new int[] {0, 1, 2, 3, 4, 5, 6, 9, 10, 11, 12, 13, 14, 15, 18, 19, 20, 21, 22, 23, 24, 27, 28, 29, 30, 31, 32, 33, 36, 37, 38, 39, 40, 41, 42};
|
||||||
private static final ItemStack terminal_noitem_item = new CustomItem(new MaterialData(Material.BARRIER), "&4No Item cached");
|
private static final ItemStack terminal_noitem_item = new CustomItem(new MaterialData(Material.BARRIER), "&4No Item cached");
|
||||||
@ -66,11 +67,20 @@ public class CargoNet {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static void tick(final Block b) {
|
public static void tick(final Block b) {
|
||||||
|
/*
|
||||||
|
Input/Output Nodes can be found here after a scan.
|
||||||
|
Input Nodes:
|
||||||
|
Location = The location of the node.
|
||||||
|
Integer = The frequency of the node.
|
||||||
|
Output Nodes:
|
||||||
|
Integer = The frequency of the node.
|
||||||
|
List<Location> = The locations of the corresponding input nodes
|
||||||
|
*/
|
||||||
final Map<Location, Integer> input = new HashMap<Location, Integer>();
|
final Map<Location, Integer> input = new HashMap<Location, Integer>();
|
||||||
final Map<Integer, List<Location>> output = new HashMap<Integer, List<Location>>();
|
final Map<Integer, List<Location>> output = new HashMap<Integer, List<Location>>();
|
||||||
|
|
||||||
|
//Chest Terminal Stuff
|
||||||
final Set<Location> providers = new HashSet<Location>();
|
final Set<Location> providers = new HashSet<Location>();
|
||||||
final Set<Location> terminals = new HashSet<Location>();
|
final Set<Location> terminals = new HashSet<Location>();
|
||||||
final Set<Location> imports = new HashSet<Location>();
|
final Set<Location> imports = new HashSet<Location>();
|
||||||
@ -103,7 +113,7 @@ public class CargoNet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//Chest Terminal Code
|
||||||
if (EXTRA_CHANNELS) {
|
if (EXTRA_CHANNELS) {
|
||||||
for (Location bus: imports) {
|
for (Location bus: imports) {
|
||||||
BlockMenu menu = BlockStorage.getInventory(bus);
|
BlockMenu menu = BlockStorage.getInventory(bus);
|
||||||
@ -225,7 +235,7 @@ public class CargoNet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//All operations happen here: Everything gets iterated from the Input Nodes. (Apart from ChestTerminal Buses)
|
||||||
for (Map.Entry<Location, Integer> entry: input.entrySet()) {
|
for (Map.Entry<Location, Integer> entry: input.entrySet()) {
|
||||||
Block inputTarget = getAttachedBlock(entry.getKey().getBlock());
|
Block inputTarget = getAttachedBlock(entry.getKey().getBlock());
|
||||||
ItemStack stack = null;
|
ItemStack stack = null;
|
||||||
@ -289,7 +299,7 @@ public class CargoNet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//Chest Terminal Code
|
||||||
if (EXTRA_CHANNELS) {
|
if (EXTRA_CHANNELS) {
|
||||||
List<StoredItem> items = new ArrayList<StoredItem>();
|
List<StoredItem> items = new ArrayList<StoredItem>();
|
||||||
for (Location l: providers) {
|
for (Location l: providers) {
|
||||||
|
Loading…
Reference in New Issue
Block a user