1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 03:35:51 +00:00

[CI skip] Reduced technical debt and tweaked Magnesium Salt

This commit is contained in:
TheBusyBiscuit 2019-12-18 01:07:04 +01:00
parent 331b9b64a7
commit f7fa6e2972
41 changed files with 161 additions and 125 deletions

View File

@ -4,13 +4,17 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
import me.mrCookieSlime.Slimefun.SlimefunGuide;
import me.mrCookieSlime.Slimefun.SlimefunPlugin; import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Lists.Categories; import me.mrCookieSlime.Slimefun.Lists.Categories;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
import me.mrCookieSlime.Slimefun.api.PlayerProfile;
/** /**
* Statically handles categories. * Statically handles categories.
@ -25,9 +29,9 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
*/ */
public class Category { public class Category {
private ItemStack item; private final ItemStack item;
private List<SlimefunItem> items; private final List<SlimefunItem> items;
private int tier; private final int tier;
/** /**
* Constructs a Category with the given display item. * Constructs a Category with the given display item.

View File

@ -15,9 +15,9 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
public class EnhancedFurnace extends SimpleSlimefunItem<BlockTicker> { public class EnhancedFurnace extends SimpleSlimefunItem<BlockTicker> {
private int speed; private final int speed;
private int efficiency; private final int efficiency;
private int fortune; private final int fortune;
public EnhancedFurnace(int speed, int efficiency, int fortune, SlimefunItemStack item, ItemStack[] recipe) { public EnhancedFurnace(int speed, int efficiency, int fortune, SlimefunItemStack item, ItemStack[] recipe) {
super(Categories.MACHINES_1, item, RecipeType.ENHANCED_CRAFTING_TABLE, recipe); super(Categories.MACHINES_1, item, RecipeType.ENHANCED_CRAFTING_TABLE, recipe);
@ -36,11 +36,11 @@ public class EnhancedFurnace extends SimpleSlimefunItem<BlockTicker> {
} }
public int getOutput() { public int getOutput() {
int fortune = this.fortune; int bonus = this.fortune;
fortune = new Random().nextInt(fortune + 2) - 1; bonus = new Random().nextInt(bonus + 2) - 1;
if (fortune <= 0) fortune = 0; if (bonus <= 0) bonus = 0;
fortune++; bonus++;
return fortune; return bonus;
} }
@Override @Override

View File

@ -6,6 +6,7 @@ package me.mrCookieSlime.Slimefun.Objects.SlimefunItem;
* @since 4.1.10 * @since 4.1.10
*/ */
public enum ItemState { public enum ItemState {
/** /**
* This SlimefunItem is enabled. * This SlimefunItem is enabled.
*/ */

View File

@ -8,7 +8,7 @@ import org.bukkit.inventory.ItemStack;
public class JetBoots extends DamagableChargableItem { public class JetBoots extends DamagableChargableItem {
private double speed; private final double speed;
public JetBoots(SlimefunItemStack item, ItemStack[] recipe, double speed) { public JetBoots(SlimefunItemStack item, ItemStack[] recipe, double speed) {
super(Categories.TECH, item, RecipeType.ENHANCED_CRAFTING_TABLE, recipe, "Jet Boots"); super(Categories.TECH, item, RecipeType.ENHANCED_CRAFTING_TABLE, recipe, "Jet Boots");

View File

@ -9,7 +9,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
public class SlimefunArmorPiece extends SlimefunItem { public class SlimefunArmorPiece extends SlimefunItem {
private PotionEffect[] effects; private final PotionEffect[] effects;
public SlimefunArmorPiece(Category category, ItemStack item, String id, RecipeType recipeType, ItemStack[] recipe, PotionEffect[] effects) { public SlimefunArmorPiece(Category category, ItemStack item, String id, RecipeType recipeType, ItemStack[] recipe, PotionEffect[] effects) {
super(category, item, id, recipeType, recipe); super(category, item, id, recipeType, recipe);

View File

@ -8,7 +8,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
public class SlimefunBackpack extends SlimefunItem { public class SlimefunBackpack extends SlimefunItem {
private int size; private final int size;
public SlimefunBackpack(int size, Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { public SlimefunBackpack(int size, Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe); super(category, item, recipeType, recipe);

View File

@ -12,6 +12,7 @@ public class SlimefunBow extends SlimefunItem {
super(Categories.WEAPONS, item, id, RecipeType.MAGIC_WORKBENCH, recipe); super(Categories.WEAPONS, item, id, RecipeType.MAGIC_WORKBENCH, recipe);
} }
@Deprecated
public SlimefunBow(SlimefunItemStack item, ItemStack[] recipe) { public SlimefunBow(SlimefunItemStack item, ItemStack[] recipe) {
super(Categories.WEAPONS, item, RecipeType.MAGIC_WORKBENCH, recipe); super(Categories.WEAPONS, item, RecipeType.MAGIC_WORKBENCH, recipe);
} }

View File

@ -100,6 +100,7 @@ public class Talisman extends SlimefunItem {
public void install() { public void install() {
EnderTalisman talisman = (EnderTalisman) SlimefunItem.getByItem(upgrade()); EnderTalisman talisman = (EnderTalisman) SlimefunItem.getByItem(upgrade());
Research research = Research.getByID(112); Research research = Research.getByID(112);
if (talisman != null) { if (talisman != null) {
Slimefun.addOfficialWikiPage(talisman.getID(), "Talismans"); Slimefun.addOfficialWikiPage(talisman.getID(), "Talismans");
if (research != null) talisman.bindToResearch(research); if (research != null) talisman.bindToResearch(research);

View File

@ -27,6 +27,7 @@ public class VanillaItem extends SlimefunItem {
*/ */
public VanillaItem(Category category, ItemStack item, String id, RecipeType recipeType, ItemStack[] recipe) { public VanillaItem(Category category, ItemStack item, String id, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, id, recipeType, recipe); super(category, item, id, recipeType, recipe);
useableInWorkbench = true; useableInWorkbench = true;
} }
} }

View File

@ -10,7 +10,7 @@ import org.bukkit.inventory.BlockInventoryHolder;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BlockStateMeta; import org.bukkit.inventory.meta.BlockStateMeta;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem; import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
import me.mrCookieSlime.Slimefun.SlimefunPlugin; import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.Category;
@ -77,7 +77,7 @@ public class BlockPlacer extends SimpleSlimefunItem<AutonomousMachineHandler> {
//Changing the inventory of the block based on the inventory of the block's itemstack (Currently only applies to shulker boxes) //Changing the inventory of the block based on the inventory of the block's itemstack (Currently only applies to shulker boxes)
//Inventory has to be changed after blockState.update() as updating it will create a different Inventory for the object //Inventory has to be changed after blockState.update() as updating it will create a different Inventory for the object
if (block.getState() instanceof BlockInventoryHolder) { if (block.getState() instanceof BlockInventoryHolder) {
((BlockInventoryHolder) block.getState()).getInventory().setContents(((BlockInventoryHolder) itemBlockState).getInventory().getContents());; ((BlockInventoryHolder) block.getState()).getInventory().setContents(((BlockInventoryHolder) itemBlockState).getInventory().getContents());
} }
} }

View File

@ -73,11 +73,7 @@ public class AnimalGrowthAccelerator extends SlimefunItem implements InventoryBl
@Override @Override
public void tick(Block b, SlimefunItem sf, Config data) { public void tick(Block b, SlimefunItem sf, Config data) {
try { AnimalGrowthAccelerator.this.tick(b);
AnimalGrowthAccelerator.this.tick(b);
} catch (Exception x) {
Slimefun.getLogger().log(Level.SEVERE, "An Error occured while ticking an Animal Growth Accelerator for Slimefun " + Slimefun.getVersion(), x);
}
} }
@Override @Override
@ -89,7 +85,7 @@ public class AnimalGrowthAccelerator extends SlimefunItem implements InventoryBl
protected void tick(Block b) { protected void tick(Block b) {
for (Entity n : b.getWorld().getNearbyEntities(b.getLocation(), 3.0, 3.0, 3.0, n -> n instanceof Ageable && n.isValid() && !((Ageable) n).isAdult())) { for (Entity n : b.getWorld().getNearbyEntities(b.getLocation(), 3.0, 3.0, 3.0, n -> n instanceof Ageable && n.isValid() && !((Ageable) n).isAdult())) {
for (int slot: getInputSlots()) { for (int slot : getInputSlots()) {
if (SlimefunManager.isItemSimilar(BlockStorage.getInventory(b).getItemInSlot(slot), SlimefunItems.ORGANIC_FOOD, false)) { if (SlimefunManager.isItemSimilar(BlockStorage.getInventory(b).getItemInSlot(slot), SlimefunItems.ORGANIC_FOOD, false)) {
if (ChargableBlock.getCharge(b) < energyConsumption) return; if (ChargableBlock.getCharge(b) < energyConsumption) return;

View File

@ -75,7 +75,7 @@ public abstract class AutoAnvil extends AContainer {
else { else {
MachineRecipe recipe = null; MachineRecipe recipe = null;
for (int slot: getInputSlots()) { for (int slot : getInputSlots()) {
ItemStack target = menu.getItemInSlot(slot == getInputSlots()[0] ? getInputSlots()[1]: getInputSlots()[0]); ItemStack target = menu.getItemInSlot(slot == getInputSlots()[0] ? getInputSlots()[1]: getInputSlots()[0]);
ItemStack item = menu.getItemInSlot(slot); ItemStack item = menu.getItemInSlot(slot);
@ -96,9 +96,10 @@ public abstract class AutoAnvil extends AContainer {
if (recipe != null) { if (recipe != null) {
if (!menu.fits(recipe.getOutput()[0], getOutputSlots())) return; if (!menu.fits(recipe.getOutput()[0], getOutputSlots())) return;
for (int slot: getInputSlots()) { for (int slot : getInputSlots()) {
menu.replaceExistingItem(slot, InvUtils.decreaseItem(menu.getItemInSlot(slot), 1)); menu.replaceExistingItem(slot, InvUtils.decreaseItem(menu.getItemInSlot(slot), 1));
} }
processing.put(b, recipe); processing.put(b, recipe);
progress.put(b, recipe.getTicks()); progress.put(b, recipe.getTicks());
} }

View File

@ -81,7 +81,7 @@ public class AutoDisenchanter extends AContainer {
else { else {
MachineRecipe recipe = null; MachineRecipe recipe = null;
Map<Enchantment, Integer> enchantments = new HashMap<>(); Map<Enchantment, Integer> enchantments = new HashMap<>();
Set<ItemEnchantment> enchantments2 = new HashSet<>(); Set<ItemEnchantment> emeraldEnchantments = new HashSet<>();
for (int slot : getInputSlots()) { for (int slot : getInputSlots()) {
ItemStack target = menu.getItemInSlot(slot == getInputSlots()[0] ? getInputSlots()[1]: getInputSlots()[0]); ItemStack target = menu.getItemInSlot(slot == getInputSlots()[0] ? getInputSlots()[1]: getInputSlots()[0]);
@ -108,15 +108,15 @@ public class AutoDisenchanter extends AContainer {
if (item != null && target != null && target.getType() == Material.BOOK) { if (item != null && target != null && target.getType() == Material.BOOK) {
int amount = 0; int amount = 0;
for (Map.Entry<Enchantment, Integer> e : item.getEnchantments().entrySet()) { for (Map.Entry<Enchantment, Integer> entry : item.getEnchantments().entrySet()) {
enchantments.put(e.getKey(), e.getValue()); enchantments.put(entry.getKey(), entry.getValue());
amount++; amount++;
} }
if (SlimefunPlugin.getHooks().isEmeraldEnchantsInstalled()) { if (SlimefunPlugin.getHooks().isEmeraldEnchantsInstalled()) {
for (ItemEnchantment enchantment : EmeraldEnchants.getInstance().getRegistry().getEnchantments(item)) { for (ItemEnchantment enchantment : EmeraldEnchants.getInstance().getRegistry().getEnchantments(item)) {
amount++; amount++;
enchantments2.add(enchantment); emeraldEnchantments.add(enchantment);
} }
} }
@ -136,16 +136,16 @@ public class AutoDisenchanter extends AContainer {
EnchantmentStorageMeta meta = (EnchantmentStorageMeta) book.getItemMeta(); EnchantmentStorageMeta meta = (EnchantmentStorageMeta) book.getItemMeta();
for (Map.Entry<Enchantment,Integer> e : enchantments.entrySet()) { for (Map.Entry<Enchantment,Integer> entry : enchantments.entrySet()) {
newItem.removeEnchantment(e.getKey()); newItem.removeEnchantment(entry.getKey());
meta.addStoredEnchant(e.getKey(), e.getValue(), true); meta.addStoredEnchant(entry.getKey(), entry.getValue(), true);
} }
book.setItemMeta(meta); book.setItemMeta(meta);
for (ItemEnchantment e : enchantments2) { for (ItemEnchantment ench : emeraldEnchantments) {
EmeraldEnchants.getInstance().getRegistry().applyEnchantment(book, e.getEnchantment(), e.getLevel()); EmeraldEnchants.getInstance().getRegistry().applyEnchantment(book, ench.getEnchantment(), ench.getLevel());
EmeraldEnchants.getInstance().getRegistry().applyEnchantment(newItem, e.getEnchantment(), 0); EmeraldEnchants.getInstance().getRegistry().applyEnchantment(newItem, ench.getEnchantment(), 0);
} }
recipe = new MachineRecipe(100 * amount, new ItemStack[] {target, item}, new ItemStack[] {newItem, book}); recipe = new MachineRecipe(100 * amount, new ItemStack[] {target, item}, new ItemStack[] {newItem, book});

View File

@ -113,7 +113,7 @@ public class AutoDrier extends AContainer implements RecipeDisplayItem {
MachineRecipe r = null; MachineRecipe r = null;
int inputSlot = -1; int inputSlot = -1;
for (int slot: getInputSlots()) { for (int slot : getInputSlots()) {
ItemStack item = menu.getItemInSlot(slot); ItemStack item = menu.getItemInSlot(slot);
if (item != null) { if (item != null) {
Material mat = item.getType(); Material mat = item.getType();

View File

@ -74,7 +74,7 @@ public class AutoEnchanter extends AContainer {
else { else {
MachineRecipe recipe = null; MachineRecipe recipe = null;
for (int slot: getInputSlots()) { for (int slot : getInputSlots()) {
ItemStack target = menu.getItemInSlot(slot == getInputSlots()[0] ? getInputSlots()[1]: getInputSlots()[0]); ItemStack target = menu.getItemInSlot(slot == getInputSlots()[0] ? getInputSlots()[1]: getInputSlots()[0]);
// Check if enchantable // Check if enchantable
SlimefunItem sfTarget = SlimefunItem.getByItem(target); SlimefunItem sfTarget = SlimefunItem.getByItem(target);
@ -85,7 +85,7 @@ public class AutoEnchanter extends AContainer {
// Enchant // Enchant
if (item != null && item.getType() == Material.ENCHANTED_BOOK && target != null) { if (item != null && item.getType() == Material.ENCHANTED_BOOK && target != null) {
Map<Enchantment, Integer> enchantments = new HashMap<>(); Map<Enchantment, Integer> enchantments = new HashMap<>();
Set<ItemEnchantment> enchantments2 = new HashSet<>(); Set<ItemEnchantment> emeraldEnchantments = new HashSet<>();
int amount = 0; int amount = 0;
int specialAmount = 0; int specialAmount = 0;
EnchantmentStorageMeta meta = (EnchantmentStorageMeta) item.getItemMeta(); EnchantmentStorageMeta meta = (EnchantmentStorageMeta) item.getItemMeta();
@ -98,11 +98,11 @@ public class AutoEnchanter extends AContainer {
} }
if (SlimefunPlugin.getHooks().isEmeraldEnchantsInstalled()) { if (SlimefunPlugin.getHooks().isEmeraldEnchantsInstalled()) {
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++;
specialAmount++; specialAmount++;
enchantments2.add(enchantment); emeraldEnchantments.add(enchantment);
} }
} }
specialAmount += EmeraldEnchants.getInstance().getRegistry().getEnchantments(target).size(); specialAmount += EmeraldEnchants.getInstance().getRegistry().getEnchantments(target).size();
@ -110,12 +110,13 @@ public class AutoEnchanter extends AContainer {
if (amount > 0 && specialAmount <= SlimefunPlugin.getSettings().emeraldEnchantsLimit) { if (amount > 0 && specialAmount <= SlimefunPlugin.getSettings().emeraldEnchantsLimit) {
ItemStack newItem = target.clone(); ItemStack newItem = target.clone();
for (Map.Entry<Enchantment, Integer> e: enchantments.entrySet()) {
newItem.addUnsafeEnchantment(e.getKey(), e.getValue()); for (Map.Entry<Enchantment, Integer> entry : enchantments.entrySet()) {
newItem.addUnsafeEnchantment(entry.getKey(), entry.getValue());
} }
for (ItemEnchantment e: enchantments2) { for (ItemEnchantment ench: emeraldEnchantments) {
EmeraldEnchants.getInstance().getRegistry().applyEnchantment(newItem, e.getEnchantment(), e.getLevel()); EmeraldEnchants.getInstance().getRegistry().applyEnchantment(newItem, ench.getEnchantment(), ench.getLevel());
} }
recipe = new MachineRecipe(75 * amount, new ItemStack[] {target, item}, new ItemStack[] {newItem, new ItemStack(Material.BOOK)}); recipe = new MachineRecipe(75 * amount, new ItemStack[] {target, item}, new ItemStack[] {newItem, new ItemStack(Material.BOOK)});

View File

@ -110,13 +110,13 @@ public abstract class AutomatedCraftingChamber extends SlimefunItem implements I
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) { public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
BlockMenu inv = BlockStorage.getInventory(b); BlockMenu inv = BlockStorage.getInventory(b);
if (inv != null) { if (inv != null) {
for (int slot: getInputSlots()) { for (int slot : getInputSlots()) {
if (inv.getItemInSlot(slot) != null) { if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null); inv.replaceExistingItem(slot, null);
} }
} }
for (int slot: getOutputSlots()) { for (int slot : getOutputSlots()) {
if (inv.getItemInSlot(slot) != null) { if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null); inv.replaceExistingItem(slot, null);

View File

@ -39,13 +39,15 @@ public class ChargingBench extends AContainer {
if (ChargableBlock.getCharge(b) < getEnergyConsumption()) return; if (ChargableBlock.getCharge(b) < getEnergyConsumption()) return;
BlockMenu menu = BlockStorage.getInventory(b); BlockMenu menu = BlockStorage.getInventory(b);
for (int slot: getInputSlots()) {
for (int slot : getInputSlots()) {
ItemStack stack = menu.getItemInSlot(slot); ItemStack stack = menu.getItemInSlot(slot);
if (ItemEnergy.getMaxEnergy(stack) > 0) { if (ItemEnergy.getMaxEnergy(stack) > 0) {
if (ItemEnergy.getStoredEnergy(stack) < ItemEnergy.getMaxEnergy(stack)) { if (ItemEnergy.getStoredEnergy(stack) < ItemEnergy.getMaxEnergy(stack)) {
ChargableBlock.addCharge(b, -getEnergyConsumption()); ChargableBlock.addCharge(b, -getEnergyConsumption());
float rest = ItemEnergy.addStoredEnergy(stack, getEnergyConsumption() / 2F); float rest = ItemEnergy.addStoredEnergy(stack, getEnergyConsumption() / 2F);
if (rest > 0F) { if (rest > 0F) {
if (menu.fits(stack, getOutputSlots())) { if (menu.fits(stack, getOutputSlots())) {
menu.pushItem(stack, getOutputSlots()); menu.pushItem(stack, getOutputSlots());

View File

@ -49,7 +49,7 @@ public abstract class CropGrowthAccelerator extends SlimefunItem implements Inve
registerBlockHandler(getID(), (p, b, tool, reason) -> { registerBlockHandler(getID(), (p, b, tool, reason) -> {
BlockMenu inv = BlockStorage.getInventory(b); BlockMenu inv = BlockStorage.getInventory(b);
if (inv != null) { if (inv != null) {
for (int slot: getInputSlots()) { for (int slot : getInputSlots()) {
if (inv.getItemInSlot(slot) != null) { if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null); inv.replaceExistingItem(slot, null);
@ -88,11 +88,7 @@ public abstract class CropGrowthAccelerator extends SlimefunItem implements Inve
@Override @Override
public void tick(Block b, SlimefunItem sf, Config data) { public void tick(Block b, SlimefunItem sf, Config data) {
try { CropGrowthAccelerator.this.tick(b);
CropGrowthAccelerator.this.tick(b);
} catch (Exception x) {
Slimefun.getLogger().log(Level.SEVERE, "An Error occured while ticking a Crop Growth Accelerator for Slimefun " + Slimefun.getVersion(), x);
}
} }
@Override @Override

View File

@ -68,13 +68,13 @@ public abstract class ElectricDustWasher extends AContainer {
else { else {
ItemStack[] items = SlimefunPlugin.getUtilities().oreWasherOutputs; ItemStack[] items = SlimefunPlugin.getUtilities().oreWasherOutputs;
for (int slot: getInputSlots()) { for (int slot : getInputSlots()) {
if (SlimefunManager.isItemSimilar(menu.getItemInSlot(slot), SlimefunItems.SIFTED_ORE, true)) { if (SlimefunManager.isItemSimilar(menu.getItemInSlot(slot), SlimefunItems.SIFTED_ORE, true)) {
if (!SlimefunPlugin.getSettings().legacyDustWasher) { if (!SlimefunPlugin.getSettings().legacyDustWasher) {
boolean emptySlot = false; boolean emptySlot = false;
for (int output_slot: getOutputSlots()) { for (int outputSlot : getOutputSlots()) {
if (menu.getItemInSlot(output_slot) == null) { if (menu.getItemInSlot(outputSlot) == null) {
emptySlot = true; emptySlot = true;
break; break;
} }

View File

@ -31,8 +31,8 @@ public abstract class ElectricFurnace extends AContainer {
} }
//Bukkit Recipe Iterator does not seem to include _LOG's of any type for charcoal... Manually adding them all. //Bukkit Recipe Iterator does not seem to include _LOG's of any type for charcoal... Manually adding them all.
for (Material mat:Tag.LOGS.getValues()) { for (Material log : Tag.LOGS.getValues()) {
registerRecipe(4, new ItemStack[] {new ItemStack(mat,1)}, new ItemStack[] {new ItemStack(Material.CHARCOAL, 1)}); registerRecipe(4, new ItemStack[] {new ItemStack(log, 1)}, new ItemStack[] {new ItemStack(Material.CHARCOAL, 1)});
} }
} }

View File

@ -115,7 +115,7 @@ public abstract class ElectricGoldPan extends AContainer implements RecipeDispla
} }
} }
else { else {
for (int slot: getInputSlots()) { for (int slot : getInputSlots()) {
if (SlimefunManager.isItemSimilar(menu.getItemInSlot(slot), new ItemStack(Material.GRAVEL), true)) { if (SlimefunManager.isItemSimilar(menu.getItemInSlot(slot), new ItemStack(Material.GRAVEL), true)) {
ItemStack output = randomizer.getRandom(); ItemStack output = randomizer.getRandom();

View File

@ -47,7 +47,7 @@ public class ElectricIngotPulverizer extends AContainer implements RecipeDisplay
public List<ItemStack> getDisplayRecipes() { public List<ItemStack> getDisplayRecipes() {
List<ItemStack> displayRecipes = new ArrayList<>(recipes.size() * 2); List<ItemStack> displayRecipes = new ArrayList<>(recipes.size() * 2);
for (MachineRecipe recipe: recipes) { for (MachineRecipe recipe : recipes) {
displayRecipes.add(recipe.getInput()[0]); displayRecipes.add(recipe.getInput()[0]);
displayRecipes.add(recipe.getOutput()[0]); displayRecipes.add(recipe.getOutput()[0]);
} }

View File

@ -92,6 +92,7 @@ public class FluidPump extends SlimefunItem implements InventoryBlock {
if (output != null && ChargableBlock.getCharge(b) >= energyConsumption) { if (output != null && ChargableBlock.getCharge(b) >= energyConsumption) {
BlockMenu menu = BlockStorage.getInventory(b); BlockMenu menu = BlockStorage.getInventory(b);
for (int slot : getInputSlots()) { for (int slot : getInputSlots()) {
if (SlimefunManager.isItemSimilar(menu.getItemInSlot(slot), new ItemStack(Material.BUCKET), true)) { if (SlimefunManager.isItemSimilar(menu.getItemInSlot(slot), new ItemStack(Material.BUCKET), true)) {
if (!menu.fits(output, getOutputSlots())) return; if (!menu.fits(output, getOutputSlots())) return;

View File

@ -95,7 +95,7 @@ public abstract class HeatedPressureChamber extends AContainer {
registerRecipe(90, new ItemStack[] {SlimefunItems.PLUTONIUM, SlimefunItems.URANIUM}, new ItemStack[] {SlimefunItems.BOOSTED_URANIUM}); registerRecipe(90, new ItemStack[] {SlimefunItems.PLUTONIUM, SlimefunItems.URANIUM}, new ItemStack[] {SlimefunItems.BOOSTED_URANIUM});
registerRecipe(60, new ItemStack[] {SlimefunItems.NETHER_ICE, SlimefunItems.PLUTONIUM}, new ItemStack[] {new CustomItem(SlimefunItems.ENRICHED_NETHER_ICE, 4)}); registerRecipe(60, new ItemStack[] {SlimefunItems.NETHER_ICE, SlimefunItems.PLUTONIUM}, new ItemStack[] {new CustomItem(SlimefunItems.ENRICHED_NETHER_ICE, 4)});
registerRecipe(45, new ItemStack[] {SlimefunItems.ENRICHED_NETHER_ICE}, new ItemStack[] {new CustomItem(SlimefunItems.NETHER_ICE_COOLANT_CELL, 8)}); registerRecipe(45, new ItemStack[] {SlimefunItems.ENRICHED_NETHER_ICE}, new ItemStack[] {new CustomItem(SlimefunItems.NETHER_ICE_COOLANT_CELL, 8)});
registerRecipe(12, new ItemStack[] {SlimefunItems.MAGNESIUM_DUST, SlimefunItems.SALT}, new ItemStack[] {SlimefunItems.MAGNESIUM_SALT}); registerRecipe(8, new ItemStack[] {SlimefunItems.MAGNESIUM_DUST, SlimefunItems.SALT}, new ItemStack[] {SlimefunItems.MAGNESIUM_SALT});
} }
@Override @Override

View File

@ -78,7 +78,9 @@ public abstract class Refinery extends AContainer implements RecipeDisplayItem {
for (int slot : getInputSlots()) { for (int slot : getInputSlots()) {
if (SlimefunManager.isItemSimilar(menu.getItemInSlot(slot), SlimefunItems.BUCKET_OF_OIL, true)) { if (SlimefunManager.isItemSimilar(menu.getItemInSlot(slot), SlimefunItems.BUCKET_OF_OIL, true)) {
MachineRecipe r = new MachineRecipe(40, new ItemStack[0], new ItemStack[] {SlimefunItems.BUCKET_OF_FUEL}); MachineRecipe r = new MachineRecipe(40, new ItemStack[0], new ItemStack[] {SlimefunItems.BUCKET_OF_FUEL});
if (!menu.fits(SlimefunItems.BUCKET_OF_FUEL, getOutputSlots())) return; if (!menu.fits(SlimefunItems.BUCKET_OF_FUEL, getOutputSlots())) return;
menu.replaceExistingItem(slot, InvUtils.decreaseItem(menu.getItemInSlot(slot), 1)); menu.replaceExistingItem(slot, InvUtils.decreaseItem(menu.getItemInSlot(slot), 1));
processing.put(b, r); processing.put(b, r);
progress.put(b, r.getTicks()); progress.put(b, r.getTicks());

View File

@ -1,7 +1,5 @@
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric; package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric;
import java.util.logging.Level;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -52,36 +50,32 @@ public class WitherAssembler extends SlimefunItem {
@Override @Override
public void newInstance(final BlockMenu menu, final Block b) { public void newInstance(final BlockMenu menu, final Block b) {
try { if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "enabled") == null || BlockStorage.getLocationInfo(b.getLocation(), "enabled").equals("false")) {
if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "enabled") == null || BlockStorage.getLocationInfo(b.getLocation(), "enabled").equals("false")) { menu.replaceExistingItem(22, new CustomItem(new ItemStack(Material.GUNPOWDER), "&7Enabled: &4\u2718", "", "&e> Click to enable this Machine"));
menu.replaceExistingItem(22, new CustomItem(new ItemStack(Material.GUNPOWDER), "&7Enabled: &4\u2718", "", "&e> Click to enable this Machine")); menu.addMenuClickHandler(22, (p, slot, item, action) -> {
menu.addMenuClickHandler(22, (p, slot, item, action) -> { BlockStorage.addBlockInfo(b, "enabled", "true");
BlockStorage.addBlockInfo(b, "enabled", "true");
newInstance(menu, b);
return false;
});
}
else {
menu.replaceExistingItem(22, new CustomItem(new ItemStack(Material.REDSTONE), "&7Enabled: &2\u2714", "", "&e> Click to disable this Machine"));
menu.addMenuClickHandler(22, (p, slot, item, action) -> {
BlockStorage.addBlockInfo(b, "enabled", "false");
newInstance(menu, b);
return false;
});
}
double offset = (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "offset") == null) ? 3.0F: Double.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "offset"));
menu.replaceExistingItem(31, new CustomItem(new ItemStack(Material.PISTON), "&7Offset: &3" + offset + " Block(s)", "", "&rLeft Click: &7+0.1", "&rRight Click: &7-0.1"));
menu.addMenuClickHandler(31, (p, slot, item, action) -> {
double offsetv = DoubleHandler.fixDouble(Double.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "offset")) + (action.isRightClicked() ? -0.1F : 0.1F));
BlockStorage.addBlockInfo(b, "offset", String.valueOf(offsetv));
newInstance(menu, b); newInstance(menu, b);
return false; return false;
}); });
} catch(Exception x) {
Slimefun.getLogger().log(Level.SEVERE, "An Error occured while creating a Wither Assembler for Slimefun " + Slimefun.getVersion(), x);
} }
else {
menu.replaceExistingItem(22, new CustomItem(new ItemStack(Material.REDSTONE), "&7Enabled: &2\u2714", "", "&e> Click to disable this Machine"));
menu.addMenuClickHandler(22, (p, slot, item, action) -> {
BlockStorage.addBlockInfo(b, "enabled", "false");
newInstance(menu, b);
return false;
});
}
double offset = (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "offset") == null) ? 3.0F: Double.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "offset"));
menu.replaceExistingItem(31, new CustomItem(new ItemStack(Material.PISTON), "&7Offset: &3" + offset + " Block(s)", "", "&rLeft Click: &7+0.1", "&rRight Click: &7-0.1"));
menu.addMenuClickHandler(31, (p, slot, item, action) -> {
double offsetv = DoubleHandler.fixDouble(Double.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "offset")) + (action.isRightClicked() ? -0.1F : 0.1F));
BlockStorage.addBlockInfo(b, "offset", String.valueOf(offsetv));
newInstance(menu, b);
return false;
});
} }
@Override @Override

View File

@ -81,11 +81,7 @@ public class XPCollector extends SlimefunItem implements InventoryBlock {
@Override @Override
public void tick(Block b, SlimefunItem sf, Config data) { public void tick(Block b, SlimefunItem sf, Config data) {
try { XPCollector.this.tick(b);
XPCollector.this.tick(b);
} catch (Exception x) {
Slimefun.getLogger().log(Level.SEVERE, "An Error occured while ticking an Exp Collector for Slimefun " + Slimefun.getVersion(), x);
}
} }
@Override @Override

View File

@ -18,7 +18,7 @@ public abstract class MagnesiumGenerator extends AGenerator {
@Override @Override
public void registerDefaultRecipes() { public void registerDefaultRecipes() {
registerFuel(new MachineFuel(10, SlimefunItems.MAGNESIUM_SALT)); registerFuel(new MachineFuel(12, SlimefunItems.MAGNESIUM_SALT));
} }
@Override @Override

View File

@ -109,7 +109,8 @@ public abstract class GEOMiner extends AContainer implements InventoryBlock, Rec
@Override @Override
public List<ItemStack> getDisplayRecipes() { public List<ItemStack> getDisplayRecipes() {
List<ItemStack> displayRecipes = new LinkedList<>(); List<ItemStack> displayRecipes = new LinkedList<>();
for (OreGenResource resource: OreGenSystem.listResources()) {
for (OreGenResource resource : OreGenSystem.listResources()) {
if (!resource.isLiquid()) { if (!resource.isLiquid()) {
displayRecipes.add(new CustomItem(resource.getItem(), "&r" + resource.getName())); displayRecipes.add(new CustomItem(resource.getItem(), "&r" + resource.getName()));
} }
@ -174,7 +175,7 @@ public abstract class GEOMiner extends AContainer implements InventoryBlock, Rec
else { else {
Chunk chunk = b.getChunk(); Chunk chunk = b.getChunk();
for (OreGenResource resource: OreGenSystem.listResources()) { for (OreGenResource resource : OreGenSystem.listResources()) {
if (!resource.isLiquid()) { if (!resource.isLiquid()) {
if (!OreGenSystem.wasResourceGenerated(resource, chunk)) { if (!OreGenSystem.wasResourceGenerated(resource, chunk)) {
SimpleHologram.update(b, "&4GEO-Scan required!"); SimpleHologram.update(b, "&4GEO-Scan required!");
@ -182,6 +183,7 @@ public abstract class GEOMiner extends AContainer implements InventoryBlock, Rec
} }
else { else {
int supplies = OreGenSystem.getSupplies(resource, chunk, false); int supplies = OreGenSystem.getSupplies(resource, chunk, false);
if (supplies > 0) { if (supplies > 0) {
MachineRecipe r = new MachineRecipe(getProcessingTime() / getSpeed(), new ItemStack[0], new ItemStack[] {resource.getItem().clone()}); MachineRecipe r = new MachineRecipe(getProcessingTime() / getSpeed(), new ItemStack[0], new ItemStack[] {resource.getItem().clone()});
if (!menu.fits(r.getOutput()[0], getOutputSlots())) return; if (!menu.fits(r.getOutput()[0], getOutputSlots())) return;

View File

@ -1,4 +1,4 @@
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric; package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.gps;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -44,6 +44,7 @@ public class ElevatorPlate extends SimpleSlimefunItem<ItemInteractionHandler> {
public ItemInteractionHandler getItemHandler() { public ItemInteractionHandler getItemHandler() {
return (e, p, item) -> { return (e, p, item) -> {
if (e.getClickedBlock() == null) return false; if (e.getClickedBlock() == null) return false;
String id = BlockStorage.checkID(e.getClickedBlock()); String id = BlockStorage.checkID(e.getClickedBlock());
if (id == null || !id.equals(getID())) return false; if (id == null || !id.equals(getID())) return false;

View File

@ -52,8 +52,10 @@ public class ArmorForge extends MultiBlockMachine {
if (craft) { if (craft) {
final ItemStack adding = RecipeType.getRecipeOutputList(this, inputs.get(i)).clone(); final ItemStack adding = RecipeType.getRecipeOutputList(this, inputs.get(i)).clone();
if (Slimefun.hasUnlocked(p, adding, true)) { if (Slimefun.hasUnlocked(p, adding, true)) {
Inventory outputInv = findOutputInventory(adding, dispBlock, inv); Inventory outputInv = findOutputInventory(adding, dispBlock, inv);
if (outputInv != null) { if (outputInv != null) {
for (int j = 0; j < 9; j++) { for (int j = 0; j < 9; j++) {
ItemStack item = inv.getContents()[j]; ItemStack item = inv.getContents()[j];
@ -64,6 +66,7 @@ public class ArmorForge extends MultiBlockMachine {
for (int j = 0; j < 4; j++) { for (int j = 0; j < 4; j++) {
int current = j; int current = j;
Bukkit.getScheduler().runTaskLater(SlimefunPlugin.instance, () -> { Bukkit.getScheduler().runTaskLater(SlimefunPlugin.instance, () -> {
if (current < 3) { if (current < 3) {
p.getWorld().playSound(p.getLocation(), Sound.BLOCK_ANVIL_USE, 1F, 2F); p.getWorld().playSound(p.getLocation(), Sound.BLOCK_ANVIL_USE, 1F, 2F);

View File

@ -46,15 +46,18 @@ public class Compressor extends MultiBlockMachine {
Block dispBlock = b.getRelative(BlockFace.DOWN); Block dispBlock = b.getRelative(BlockFace.DOWN);
Dispenser disp = (Dispenser) dispBlock.getState(); Dispenser disp = (Dispenser) dispBlock.getState();
Inventory inv = disp.getInventory(); Inventory inv = disp.getInventory();
for (ItemStack current: inv.getContents()) {
for (ItemStack convert: RecipeType.getRecipeInputs(this)) { for (ItemStack current : inv.getContents()) {
for (ItemStack convert : RecipeType.getRecipeInputs(this)) {
if (convert != null && SlimefunManager.isItemSimilar(current, convert, true)) { if (convert != null && SlimefunManager.isItemSimilar(current, convert, true)) {
final ItemStack adding = RecipeType.getRecipeOutput(this, convert); final ItemStack adding = RecipeType.getRecipeOutput(this, convert);
Inventory outputInv = findOutputInventory(adding, dispBlock, inv); Inventory outputInv = findOutputInventory(adding, dispBlock, inv);
if (outputInv != null) { if (outputInv != null) {
ItemStack removing = current.clone(); ItemStack removing = current.clone();
removing.setAmount(convert.getAmount()); removing.setAmount(convert.getAmount());
inv.removeItem(removing); inv.removeItem(removing);
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
int j = i; int j = i;
@ -66,7 +69,7 @@ public class Compressor extends MultiBlockMachine {
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F); p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F);
outputInv.addItem(adding); outputInv.addItem(adding);
} }
}, i*20L); }, i * 20L);
} }
} }
else SlimefunPlugin.getLocal().sendMessage(p, "machines.full-inventory", true); else SlimefunPlugin.getLocal().sendMessage(p, "machines.full-inventory", true);

View File

@ -54,6 +54,7 @@ public class EnhancedCraftingTable extends MultiBlockMachine {
for (int i = 0; i < inputs.size(); i++) { for (int i = 0; i < inputs.size(); i++) {
boolean craft = true; boolean craft = true;
for (int j = 0; j < inv.getContents().length; j++) { for (int j = 0; j < inv.getContents().length; j++) {
if (!SlimefunManager.isItemSimilar(inv.getContents()[j], inputs.get(i)[j], true)) { if (!SlimefunManager.isItemSimilar(inv.getContents()[j], inputs.get(i)[j], true)) {
if (SlimefunItem.getByItem(inputs.get(i)[j]) instanceof SlimefunBackpack) { if (SlimefunItem.getByItem(inputs.get(i)[j]) instanceof SlimefunBackpack) {
@ -92,11 +93,12 @@ public class EnhancedCraftingTable extends MultiBlockMachine {
break; break;
} }
} }
String id = ""; String id = "";
int size = ((SlimefunBackpack) sfItem).getSize(); int size = ((SlimefunBackpack) sfItem).getSize();
if (backpack != null) { if (backpack != null) {
for (String line: backpack.getItemMeta().getLore()) { for (String line : backpack.getItemMeta().getLore()) {
if (line.startsWith(ChatColor.translateAlternateColorCodes('&', "&7ID: ")) && line.contains("#")) { if (line.startsWith(ChatColor.translateAlternateColorCodes('&', "&7ID: ")) && line.contains("#")) {
id = line.replace(ChatColor.translateAlternateColorCodes('&', "&7ID: "), ""); id = line.replace(ChatColor.translateAlternateColorCodes('&', "&7ID: "), "");
PlayerProfile.fromUUID(UUID.fromString(id.split("#")[0])).getBackpack(Integer.parseInt(id.split("#")[1])).setSize(size); PlayerProfile.fromUUID(UUID.fromString(id.split("#")[0])).getBackpack(Integer.parseInt(id.split("#")[1])).setSize(size);
@ -131,6 +133,7 @@ public class EnhancedCraftingTable extends MultiBlockMachine {
for (int j = 0; j < 9; j++) { for (int j = 0; j < 9; j++) {
ItemStack item = inv.getContents()[j]; ItemStack item = inv.getContents()[j];
if (item != null && item.getType() != Material.AIR) { if (item != null && item.getType() != Material.AIR) {
ItemUtils.consumeItem(item, true); ItemUtils.consumeItem(item, true);
} }

View File

@ -43,8 +43,9 @@ public class Juicer extends MultiBlockMachine {
Block dispBlock = b.getRelative(BlockFace.DOWN); Block dispBlock = b.getRelative(BlockFace.DOWN);
Dispenser disp = (Dispenser) dispBlock.getState(); Dispenser disp = (Dispenser) dispBlock.getState();
Inventory inv = disp.getInventory(); Inventory inv = disp.getInventory();
for (ItemStack current: inv.getContents()) {
for (ItemStack convert: RecipeType.getRecipeInputs(this)) { for (ItemStack current : inv.getContents()) {
for (ItemStack convert : RecipeType.getRecipeInputs(this)) {
if (convert != null && SlimefunManager.isItemSimilar(current, convert, true)) { if (convert != null && SlimefunManager.isItemSimilar(current, convert, true)) {
ItemStack adding = RecipeType.getRecipeOutput(this, convert); ItemStack adding = RecipeType.getRecipeOutput(this, convert);
Inventory outputInv = findOutputInventory(adding, dispBlock, inv); Inventory outputInv = findOutputInventory(adding, dispBlock, inv);

View File

@ -52,11 +52,12 @@ public class MagicWorkbench extends MultiBlockMachine {
else if (b.getRelative(0, 0, -1).getType() == Material.DISPENSER) dispBlock = b.getRelative(0, 0, -1); else if (b.getRelative(0, 0, -1).getType() == Material.DISPENSER) dispBlock = b.getRelative(0, 0, -1);
Dispenser disp = (Dispenser) dispBlock.getState(); Dispenser disp = (Dispenser) dispBlock.getState();
final Inventory inv = disp.getInventory(); Inventory inv = disp.getInventory();
List<ItemStack[]> inputs = RecipeType.getRecipeInputList(this); List<ItemStack[]> inputs = RecipeType.getRecipeInputList(this);
for (int i = 0; i < inputs.size(); i++) { for (int i = 0; i < inputs.size(); i++) {
boolean craft = true; boolean craft = true;
for (int j = 0; j < inv.getContents().length; j++) { for (int j = 0; j < inv.getContents().length; j++) {
if (!SlimefunManager.isItemSimilar(inv.getContents()[j], inputs.get(i)[j], true)) { if (!SlimefunManager.isItemSimilar(inv.getContents()[j], inputs.get(i)[j], true)) {
if (SlimefunItem.getByItem(inputs.get(i)[j]) instanceof SlimefunBackpack) { if (SlimefunItem.getByItem(inputs.get(i)[j]) instanceof SlimefunBackpack) {
@ -73,7 +74,8 @@ public class MagicWorkbench extends MultiBlockMachine {
} }
if (craft) { if (craft) {
final ItemStack adding = RecipeType.getRecipeOutputList(this, inputs.get(i)).clone(); ItemStack adding = RecipeType.getRecipeOutputList(this, inputs.get(i)).clone();
if (Slimefun.hasUnlocked(p, adding, true)) { if (Slimefun.hasUnlocked(p, adding, true)) {
Inventory inv2 = Bukkit.createInventory(null, 9, "test"); Inventory inv2 = Bukkit.createInventory(null, 9, "test");
@ -99,7 +101,7 @@ public class MagicWorkbench extends MultiBlockMachine {
int size = ((SlimefunBackpack) sfItem).getSize(); int size = ((SlimefunBackpack) sfItem).getSize();
if (backpack != null) { if (backpack != null) {
for (String line: backpack.getItemMeta().getLore()) { for (String line : backpack.getItemMeta().getLore()) {
if (line.startsWith(ChatColor.translateAlternateColorCodes('&', "&7ID: ")) && line.contains("#")) { if (line.startsWith(ChatColor.translateAlternateColorCodes('&', "&7ID: ")) && line.contains("#")) {
id = line.replace(ChatColor.translateAlternateColorCodes('&', "&7ID: "), ""); id = line.replace(ChatColor.translateAlternateColorCodes('&', "&7ID: "), "");
PlayerProfile.fromUUID(UUID.fromString(id.split("#")[0])).getBackpack(Integer.parseInt(id.split("#")[1])).setSize(size); PlayerProfile.fromUUID(UUID.fromString(id.split("#")[0])).getBackpack(Integer.parseInt(id.split("#")[1])).setSize(size);
@ -137,14 +139,17 @@ public class MagicWorkbench extends MultiBlockMachine {
else inv.setItem(j, null); else inv.setItem(j, null);
} }
} }
for (int j = 0; j < 4; j++) { for (int j = 0; j < 4; j++) {
int current = j; int current = j;
Bukkit.getScheduler().runTaskLater(SlimefunPlugin.instance, () -> { Bukkit.getScheduler().runTaskLater(SlimefunPlugin.instance, () -> {
p.getWorld().playEffect(b.getLocation(), Effect.MOBSPAWNER_FLAMES, 1); p.getWorld().playEffect(b.getLocation(), Effect.MOBSPAWNER_FLAMES, 1);
p.getWorld().playEffect(b.getLocation(), Effect.ENDER_SIGNAL, 1); p.getWorld().playEffect(b.getLocation(), Effect.ENDER_SIGNAL, 1);
if (current < 3) { if (current < 3) {
p.getWorld().playSound(b.getLocation(), Sound.BLOCK_WOODEN_BUTTON_CLICK_ON, 1F, 1F); p.getWorld().playSound(b.getLocation(), Sound.BLOCK_WOODEN_BUTTON_CLICK_ON, 1F, 1F);
} else { }
else {
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F); p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F);
outputInv.addItem(adding); outputInv.addItem(adding);
} }

View File

@ -59,8 +59,9 @@ public class OreCrusher extends MultiBlockMachine {
Block dispBlock = b.getRelative(BlockFace.DOWN); Block dispBlock = b.getRelative(BlockFace.DOWN);
Dispenser disp = (Dispenser) dispBlock.getState(); Dispenser disp = (Dispenser) dispBlock.getState();
Inventory inv = disp.getInventory(); Inventory inv = disp.getInventory();
for (ItemStack current: inv.getContents()) {
for (ItemStack convert: RecipeType.getRecipeInputs(this)) { for (ItemStack current : inv.getContents()) {
for (ItemStack convert : RecipeType.getRecipeInputs(this)) {
if (convert != null && SlimefunManager.isItemSimilar(current, convert, true)) { if (convert != null && SlimefunManager.isItemSimilar(current, convert, true)) {
ItemStack adding = RecipeType.getRecipeOutput(this, convert); ItemStack adding = RecipeType.getRecipeOutput(this, convert);
Inventory outputInv = findOutputInventory(adding, dispBlock, inv); Inventory outputInv = findOutputInventory(adding, dispBlock, inv);

View File

@ -33,7 +33,7 @@ public class TableSaw extends MultiBlockMachine {
BlockFace.SELF BlockFace.SELF
); );
for (Material log: Tag.LOGS.getValues()) { for (Material log : Tag.LOGS.getValues()) {
Optional<Material> planks = MaterialConverter.getPlanksFromLog(log); Optional<Material> planks = MaterialConverter.getPlanksFromLog(log);
if (planks.isPresent()) { if (planks.isPresent()) {

View File

@ -132,7 +132,6 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.Electric
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.ElectricPress; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.ElectricPress;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.ElectricSmeltery; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.ElectricSmeltery;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.ElectrifiedCrucible; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.ElectrifiedCrucible;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.ElevatorPlate;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.EnergyRegulator; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.EnergyRegulator;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.FluidPump; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.FluidPump;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.FoodComposter; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.FoodComposter;
@ -151,6 +150,7 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.geo.GEOM
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.geo.GEOScannerBlock; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.geo.GEOScannerBlock;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.geo.NetherDrill; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.geo.NetherDrill;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.geo.OilPump; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.geo.OilPump;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.gps.ElevatorPlate;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.gps.GPSTransmitter; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.gps.GPSTransmitter;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.multiblocks.ArmorForge; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.multiblocks.ArmorForge;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.multiblocks.AutomatedPanningMachine; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.multiblocks.AutomatedPanningMachine;

View File

@ -142,4 +142,4 @@ public class BlockInfoConfig extends Config {
return new GsonBuilder().create().toJson(data); return new GsonBuilder().create().toJson(data);
} }
} }

View File

@ -96,7 +96,7 @@ public class BlockStorage {
long totalBlocks = 0; long totalBlocks = 0;
try { try {
for (File file: f.listFiles()) { for (File file : f.listFiles()) {
if (file.getName().equals("null.sfb")) { if (file.getName().equals("null.sfb")) {
Slimefun.getLogger().log(Level.WARNING, "Corrupted file detected!"); Slimefun.getLogger().log(Level.WARNING, "Corrupted file detected!");
Slimefun.getLogger().log(Level.WARNING, "Slimefun will simply skip this File, but you"); Slimefun.getLogger().log(Level.WARNING, "Slimefun will simply skip this File, but you");
@ -110,7 +110,7 @@ public class BlockStorage {
} }
FileConfiguration cfg = YamlConfiguration.loadConfiguration(file); FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);
for (String key: cfg.getKeys(false)) { for (String key : cfg.getKeys(false)) {
Location l = deserializeLocation(key); Location l = deserializeLocation(key);
String chunkString = locationToChunkString(l); String chunkString = locationToChunkString(l);
try { try {
@ -158,9 +158,11 @@ public class BlockStorage {
else f.mkdirs(); else f.mkdirs();
File chunks = new File(path_chunks + "chunks.sfc"); File chunks = new File(path_chunks + "chunks.sfc");
if (chunks.exists()) { if (chunks.exists()) {
FileConfiguration cfg = YamlConfiguration.loadConfiguration(chunks); FileConfiguration cfg = YamlConfiguration.loadConfiguration(chunks);
for (String key: cfg.getKeys(false)) {
for (String key : cfg.getKeys(false)) {
try { try {
if (world.getName().equals(key.split(";")[0])) { if (world.getName().equals(key.split(";")[0])) {
SlimefunPlugin.getUtilities().mapChunks.put(key, new BlockInfoConfig(parseJSON(cfg.getString(key)))); SlimefunPlugin.getUtilities().mapChunks.put(key, new BlockInfoConfig(parseJSON(cfg.getString(key))));
@ -173,13 +175,14 @@ public class BlockStorage {
SlimefunPlugin.getUtilities().worlds.put(world.getName(), this); SlimefunPlugin.getUtilities().worlds.put(world.getName(), this);
for (File file: new File("data-storage/Slimefun/stored-inventories").listFiles()) { for (File file : new File("data-storage/Slimefun/stored-inventories").listFiles()) {
if (file.getName().startsWith(w.getName()) && file.getName().endsWith(".sfi")) { if (file.getName().startsWith(w.getName()) && file.getName().endsWith(".sfi")) {
Location l = deserializeLocation(file.getName().replace(".sfi", "")); Location l = deserializeLocation(file.getName().replace(".sfi", ""));
Config cfg = new Config(file); Config cfg = new Config(file);
try { try {
BlockMenuPreset preset = BlockMenuPreset.getPreset(cfg.getString("preset")); BlockMenuPreset preset = BlockMenuPreset.getPreset(cfg.getString("preset"));
if (preset == null) { if (preset == null) {
preset = BlockMenuPreset.getPreset(checkID(l)); preset = BlockMenuPreset.getPreset(checkID(l));
} }
@ -194,7 +197,7 @@ public class BlockStorage {
} }
} }
for (File file: new File("data-storage/Slimefun/universal-inventories").listFiles()) { for (File file : new File("data-storage/Slimefun/universal-inventories").listFiles()) {
if (file.getName().endsWith(".sfi")) { if (file.getName().endsWith(".sfi")) {
Config cfg = new Config(file); Config cfg = new Config(file);
BlockMenuPreset preset = BlockMenuPreset.getPreset(cfg.getString("preset")); BlockMenuPreset preset = BlockMenuPreset.getPreset(cfg.getString("preset"));
@ -213,12 +216,12 @@ public class BlockStorage {
changes = blocksCache.size() + chunkChanges; changes = blocksCache.size() + chunkChanges;
Map<Location, BlockMenu> inventories2 = new HashMap<>(inventories); Map<Location, BlockMenu> inventories2 = new HashMap<>(inventories);
for (Map.Entry<Location, BlockMenu> entry: inventories2.entrySet()) { for (Map.Entry<Location, BlockMenu> entry : inventories2.entrySet()) {
changes += entry.getValue().getUnsavedChanges(); changes += entry.getValue().getUnsavedChanges();
} }
Map<String, UniversalBlockMenu> universalInventories2 = new HashMap<>(SlimefunPlugin.getUtilities().universalInventories); Map<String, UniversalBlockMenu> universalInventories2 = new HashMap<>(SlimefunPlugin.getUtilities().universalInventories);
for (Map.Entry<String, UniversalBlockMenu> entry: universalInventories2.entrySet()) { for (Map.Entry<String, UniversalBlockMenu> entry : universalInventories2.entrySet()) {
changes += entry.getValue().getUnsavedChanges(); changes += entry.getValue().getUnsavedChanges();
} }
} }
@ -239,7 +242,7 @@ public class BlockStorage {
Map<String, Config> cache = new HashMap<>(blocksCache); Map<String, Config> cache = new HashMap<>(blocksCache);
for (Map.Entry<String, Config> entry: cache.entrySet()) { for (Map.Entry<String, Config> entry : cache.entrySet()) {
blocksCache.remove(entry.getKey()); blocksCache.remove(entry.getKey());
Config cfg = entry.getValue(); Config cfg = entry.getValue();
@ -263,13 +266,13 @@ public class BlockStorage {
Map<Location, BlockMenu> inventories2 = new HashMap<>(inventories); Map<Location, BlockMenu> inventories2 = new HashMap<>(inventories);
for (Map.Entry<Location, BlockMenu> entry: inventories2.entrySet()) { for (Map.Entry<Location, BlockMenu> entry : inventories2.entrySet()) {
entry.getValue().save(entry.getKey()); entry.getValue().save(entry.getKey());
} }
Map<String, UniversalBlockMenu> universalInventories2 = new HashMap<>(SlimefunPlugin.getUtilities().universalInventories); Map<String, UniversalBlockMenu> universalInventories2 = new HashMap<>(SlimefunPlugin.getUtilities().universalInventories);
for (Map.Entry<String, UniversalBlockMenu> entry: universalInventories2.entrySet()) { for (Map.Entry<String, UniversalBlockMenu> entry : universalInventories2.entrySet()) {
entry.getValue().save(); entry.getValue().save();
} }
@ -277,7 +280,7 @@ public class BlockStorage {
File chunks = new File(path_chunks + "chunks.sfc"); File chunks = new File(path_chunks + "chunks.sfc");
Config cfg = new Config(path_chunks + "chunks.temp"); Config cfg = new Config(path_chunks + "chunks.temp");
for (Map.Entry<String, BlockInfoConfig> entry: SlimefunPlugin.getUtilities().mapChunks.entrySet()) { for (Map.Entry<String, BlockInfoConfig> entry : SlimefunPlugin.getUtilities().mapChunks.entrySet()) {
cfg.setValue(entry.getKey(), entry.getValue().toJSON()); cfg.setValue(entry.getKey(), entry.getValue().toJSON());
} }
@ -342,7 +345,8 @@ public class BlockStorage {
if (json != null && json.length() > 2) { if (json != null && json.length() > 2) {
JsonParser parser = new JsonParser(); JsonParser parser = new JsonParser();
JsonObject obj = parser.parse(json).getAsJsonObject(); JsonObject obj = parser.parse(json).getAsJsonObject();
for (Map.Entry<String, JsonElement> entry: obj.entrySet()) {
for (Map.Entry<String, JsonElement> entry : obj.entrySet()) {
map.put(entry.getKey(), entry.getValue().getAsString()); map.put(entry.getKey(), entry.getValue().getAsString());
} }
} }
@ -367,9 +371,11 @@ public class BlockStorage {
private static String serializeBlockInfo(Config cfg) { private static String serializeBlockInfo(Config cfg) {
JsonObject json = new JsonObject(); JsonObject json = new JsonObject();
for (String key : cfg.getKeys()) { for (String key : cfg.getKeys()) {
json.add(key, new JsonPrimitive(cfg.getString(key))); json.add(key, new JsonPrimitive(cfg.getString(key)));
} }
return json.toString(); return json.toString();
} }
@ -426,6 +432,7 @@ public class BlockStorage {
public static void setBlockInfo(Location l, Config cfg, boolean updateTicker) { public static void setBlockInfo(Location l, Config cfg, boolean updateTicker) {
BlockStorage storage = getStorage(l.getWorld()); BlockStorage storage = getStorage(l.getWorld());
storage.storage.put(l, cfg); storage.storage.put(l, cfg);
if (BlockMenuPreset.isInventory(cfg.getString("id"))) { if (BlockMenuPreset.isInventory(cfg.getString("id"))) {
if (BlockMenuPreset.isUniversalInventory(cfg.getString("id"))) { if (BlockMenuPreset.isUniversalInventory(cfg.getString("id"))) {
if (!SlimefunPlugin.getUtilities().universalInventories.containsKey(cfg.getString("id"))) { if (!SlimefunPlugin.getUtilities().universalInventories.containsKey(cfg.getString("id"))) {
@ -439,6 +446,7 @@ public class BlockStorage {
else storage.loadInventory(l, BlockMenuPreset.getPreset(cfg.getString("id"))); else storage.loadInventory(l, BlockMenuPreset.getPreset(cfg.getString("id")));
} }
} }
refreshCache(getStorage(l.getWorld()), l, cfg.getString("id"), serializeBlockInfo(cfg), updateTicker); refreshCache(getStorage(l.getWorld()), l, cfg.getString("id"), serializeBlockInfo(cfg), updateTicker);
} }
@ -470,6 +478,7 @@ public class BlockStorage {
public static void _integrated_removeBlockInfo(Location l, boolean destroy) { public static void _integrated_removeBlockInfo(Location l, boolean destroy) {
BlockStorage storage = getStorage(l.getWorld()); BlockStorage storage = getStorage(l.getWorld());
if (hasBlockInfo(l)) { if (hasBlockInfo(l)) {
refreshCache(storage, l, getLocationInfo(l).getString("id"), null, destroy); refreshCache(storage, l, getLocationInfo(l).getString("id"), null, destroy);
storage.storage.remove(l); storage.storage.remove(l);
@ -477,14 +486,17 @@ public class BlockStorage {
if (destroy) { if (destroy) {
if (storage.hasInventory(l)) storage.clearInventory(l); if (storage.hasInventory(l)) storage.clearInventory(l);
if (storage.hasUniversalInventory(l)) { if (storage.hasUniversalInventory(l)) {
storage.getUniversalInventory(l).close(); storage.getUniversalInventory(l).close();
storage.getUniversalInventory(l).save(); storage.getUniversalInventory(l).save();
} }
String chunkString = locationToChunkString(l); String chunkString = locationToChunkString(l);
if (SlimefunPlugin.getUtilities().tickingChunks.containsKey(chunkString)) { if (SlimefunPlugin.getUtilities().tickingChunks.containsKey(chunkString)) {
Set<Location> locations = SlimefunPlugin.getUtilities().tickingChunks.get(chunkString); Set<Location> locations = SlimefunPlugin.getUtilities().tickingChunks.get(chunkString);
locations.remove(l); locations.remove(l);
if (locations.isEmpty()) { if (locations.isEmpty()) {
SlimefunPlugin.getUtilities().tickingChunks.remove(chunkString); SlimefunPlugin.getUtilities().tickingChunks.remove(chunkString);
SlimefunPlugin.getUtilities().loadedTickers.remove(chunkString); SlimefunPlugin.getUtilities().loadedTickers.remove(chunkString);
@ -513,6 +525,7 @@ public class BlockStorage {
BlockStorage storage = getStorage(from.getWorld()); BlockStorage storage = getStorage(from.getWorld());
setBlockInfo(to, getLocationInfo(from), true); setBlockInfo(to, getLocationInfo(from), true);
if (storage.inventories.containsKey(from)) { if (storage.inventories.containsKey(from)) {
BlockMenu menu = storage.inventories.get(from); BlockMenu menu = storage.inventories.get(from);
storage.inventories.put(to, menu); storage.inventories.put(to, menu);
@ -524,9 +537,11 @@ public class BlockStorage {
storage.storage.remove(from); storage.storage.remove(from);
String chunkString = locationToChunkString(from); String chunkString = locationToChunkString(from);
if (SlimefunPlugin.getUtilities().tickingChunks.containsKey(chunkString)) { if (SlimefunPlugin.getUtilities().tickingChunks.containsKey(chunkString)) {
Set<Location> locations = SlimefunPlugin.getUtilities().tickingChunks.get(chunkString); Set<Location> locations = SlimefunPlugin.getUtilities().tickingChunks.get(chunkString);
locations.remove(from); locations.remove(from);
if (locations.isEmpty()) { if (locations.isEmpty()) {
SlimefunPlugin.getUtilities().tickingChunks.remove(chunkString); SlimefunPlugin.getUtilities().tickingChunks.remove(chunkString);
SlimefunPlugin.getUtilities().loadedTickers.remove(chunkString); SlimefunPlugin.getUtilities().loadedTickers.remove(chunkString);
@ -541,8 +556,10 @@ public class BlockStorage {
if (updateTicker) { if (updateTicker) {
SlimefunItem item = SlimefunItem.getByID(key); SlimefunItem item = SlimefunItem.getByID(key);
if (item != null && item.isTicking()) { if (item != null && item.isTicking()) {
String chunkString = locationToChunkString(l); String chunkString = locationToChunkString(l);
if (value != null) { if (value != null) {
Set<Location> locations = SlimefunPlugin.getUtilities().tickingChunks.get(chunkString); Set<Location> locations = SlimefunPlugin.getUtilities().tickingChunks.get(chunkString);
if (locations == null) locations = new HashSet<>(); if (locations == null) locations = new HashSet<>();
@ -615,9 +632,11 @@ public class BlockStorage {
@Deprecated @Deprecated
public static Set<Block> getTickingBlocks(String chunk) { public static Set<Block> getTickingBlocks(String chunk) {
Set<Block> ret = new HashSet<>(); Set<Block> ret = new HashSet<>();
for (Location l: getTickingLocations(chunk)) {
for (Location l : getTickingLocations(chunk)) {
ret.add(l.getBlock()); ret.add(l.getBlock());
} }
return ret; return ret;
} }

View File

@ -7,6 +7,7 @@ import org.bukkit.entity.Player;
import me.mrCookieSlime.CSCoreLibPlugin.PlayerRunnable; import me.mrCookieSlime.CSCoreLibPlugin.PlayerRunnable;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
@Deprecated
public interface GuideHandler { public interface GuideHandler {
public abstract void addEntry(List<String> texts, List<String> tooltips); public abstract void addEntry(List<String> texts, List<String> tooltips);