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:
parent
331b9b64a7
commit
f7fa6e2972
@ -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.
|
||||||
|
@ -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
|
||||||
|
@ -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.
|
||||||
*/
|
*/
|
||||||
|
@ -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");
|
||||||
|
@ -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);
|
||||||
|
@ -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);
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
@ -99,6 +99,7 @@ public abstract class AutoAnvil extends AContainer {
|
|||||||
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());
|
||||||
}
|
}
|
||||||
|
@ -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});
|
||||||
|
@ -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();
|
||||||
@ -102,7 +102,7 @@ public class AutoEnchanter extends AContainer {
|
|||||||
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)});
|
||||||
|
@ -39,6 +39,7 @@ 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) {
|
||||||
@ -46,6 +47,7 @@ public class ChargingBench extends AContainer {
|
|||||||
|
|
||||||
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());
|
||||||
|
@ -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
|
||||||
|
@ -73,8 +73,8 @@ public abstract class ElectricDustWasher extends AContainer {
|
|||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -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)});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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;
|
||||||
|
@ -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
|
||||||
|
@ -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());
|
||||||
|
@ -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,7 +50,6 @@ 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) -> {
|
||||||
@ -79,9 +76,6 @@ public class WitherAssembler extends SlimefunItem {
|
|||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -109,6 +109,7 @@ 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()));
|
||||||
@ -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;
|
||||||
|
@ -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;
|
||||||
|
|
@ -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);
|
||||||
|
@ -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 current : inv.getContents()) {
|
||||||
for (ItemStack convert : RecipeType.getRecipeInputs(this)) {
|
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;
|
||||||
|
|
||||||
|
@ -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,6 +93,7 @@ public class EnhancedCraftingTable extends MultiBlockMachine {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String id = "";
|
String id = "";
|
||||||
int size = ((SlimefunBackpack) sfItem).getSize();
|
int size = ((SlimefunBackpack) sfItem).getSize();
|
||||||
|
|
||||||
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,7 @@ 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 current : inv.getContents()) {
|
||||||
for (ItemStack convert : RecipeType.getRecipeInputs(this)) {
|
for (ItemStack convert : RecipeType.getRecipeInputs(this)) {
|
||||||
if (convert != null && SlimefunManager.isItemSimilar(current, convert, true)) {
|
if (convert != null && SlimefunManager.isItemSimilar(current, convert, true)) {
|
||||||
|
@ -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");
|
||||||
|
|
||||||
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,7 @@ 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 current : inv.getContents()) {
|
||||||
for (ItemStack convert : RecipeType.getRecipeInputs(this)) {
|
for (ItemStack convert : RecipeType.getRecipeInputs(this)) {
|
||||||
if (convert != null && SlimefunManager.isItemSimilar(current, convert, true)) {
|
if (convert != null && SlimefunManager.isItemSimilar(current, convert, true)) {
|
||||||
|
@ -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;
|
||||||
|
@ -158,8 +158,10 @@ 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])) {
|
||||||
@ -180,6 +182,7 @@ public class BlockStorage {
|
|||||||
|
|
||||||
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));
|
||||||
}
|
}
|
||||||
@ -342,6 +345,7 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user