mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
Added EmeraldEnchants limit to AutoEnchanter.
Started "documenting" the API
This commit is contained in:
parent
d819e1d6bc
commit
de4f779a64
@ -8,6 +8,7 @@ options:
|
||||
auto-save-delay-in-minutes: 10
|
||||
show-vanilla-recipes-in-guide: true
|
||||
allow-free-creative-research: true
|
||||
emerald-enchantment-limit: 2
|
||||
guide:
|
||||
default-view-book: false
|
||||
URID:
|
||||
|
@ -29,6 +29,7 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.material.MaterialData;
|
||||
|
||||
public class AutoEnchanter extends AContainer {
|
||||
public static int max_emerald_enchantments = 2;
|
||||
|
||||
public AutoEnchanter(Category category, ItemStack item, String name, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, item, name, recipeType, recipe);
|
||||
@ -96,6 +97,7 @@ public class AutoEnchanter extends AContainer {
|
||||
Map<Enchantment, Integer> enchantments = new HashMap<Enchantment, Integer>();
|
||||
Set<ItemEnchantment> enchantments2 = new HashSet<ItemEnchantment>();
|
||||
int amount = 0;
|
||||
int special_amount = 0;
|
||||
EnchantmentStorageMeta meta = (EnchantmentStorageMeta) item.getItemMeta();
|
||||
for (Map.Entry<Enchantment, Integer> e: meta.getStoredEnchants().entrySet()) {
|
||||
if (e.getKey().canEnchantItem(target)) {
|
||||
@ -107,12 +109,13 @@ public class AutoEnchanter extends AContainer {
|
||||
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()) {
|
||||
amount++;
|
||||
special_amount++;
|
||||
enchantments2.add(enchantment);
|
||||
}
|
||||
}
|
||||
special_amount+=EmeraldEnchants.getInstance().getRegistry().getEnchantments(target).size();
|
||||
}
|
||||
|
||||
if (amount > 0) {
|
||||
if (amount > 0 && special_amount <= max_emerald_enchantments) {
|
||||
ItemStack newItem = target.clone();
|
||||
for (Map.Entry<Enchantment, Integer> e: enchantments.entrySet()) {
|
||||
newItem.addUnsafeEnchantment(e.getKey(), e.getValue());
|
||||
|
@ -15,6 +15,7 @@ import java.util.Map;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.AutoEnchanter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
@ -385,6 +386,9 @@ public class SlimefunStartup extends JavaPlugin {
|
||||
if (clearlag) new ClearLaggIntegration(this);
|
||||
|
||||
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
|
||||
CSCoreLib.getLib().filterLog("([A-Za-z0-9_]{3,16}) issued server command: /sf elevator (.{0,})");
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ public class CargoManager {
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
//Whitelist or blacklist slots
|
||||
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) {
|
||||
|
@ -56,6 +56,7 @@ public class CargoNet {
|
||||
|
||||
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();
|
||||
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");
|
||||
@ -66,11 +67,20 @@ public class CargoNet {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
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<Integer, List<Location>> output = new HashMap<Integer, List<Location>>();
|
||||
|
||||
//Chest Terminal Stuff
|
||||
final Set<Location> providers = new HashSet<Location>();
|
||||
final Set<Location> terminals = new HashSet<Location>();
|
||||
final Set<Location> imports = new HashSet<Location>();
|
||||
@ -103,7 +113,7 @@ public class CargoNet {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Chest Terminal Code
|
||||
if (EXTRA_CHANNELS) {
|
||||
for (Location bus: imports) {
|
||||
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()) {
|
||||
Block inputTarget = getAttachedBlock(entry.getKey().getBlock());
|
||||
ItemStack stack = null;
|
||||
@ -289,7 +299,7 @@ public class CargoNet {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Chest Terminal Code
|
||||
if (EXTRA_CHANNELS) {
|
||||
List<StoredItem> items = new ArrayList<StoredItem>();
|
||||
for (Location l: providers) {
|
||||
|
Loading…
Reference in New Issue
Block a user