mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
Reduced technical debt
This commit is contained in:
parent
b075779f6b
commit
3368c56c62
@ -391,13 +391,17 @@ public class SlimefunItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void install() {}
|
public void install() {
|
||||||
|
// Deprecated
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use {@link SlimefunItem#postRegister()} instead
|
* @deprecated Use {@link SlimefunItem#postRegister()} instead
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void create() {}
|
public void create() {
|
||||||
|
// Deprecated
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use {@link SlimefunItem#addItemHandler(ItemHandler...)} instead
|
* @deprecated Use {@link SlimefunItem#addItemHandler(ItemHandler...)} instead
|
||||||
@ -524,7 +528,10 @@ public class SlimefunItem {
|
|||||||
ChargableBlock.registerCapacitor(id, capacity);
|
ChargableBlock.registerCapacitor(id, capacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void postRegister() {}
|
public void postRegister() {
|
||||||
|
// Override this method to execute code after the Item has been registered
|
||||||
|
// Useful for calls to Slimefun.getItemValue(...)
|
||||||
|
}
|
||||||
|
|
||||||
protected void setItem(ItemStack stack) {
|
protected void setItem(ItemStack stack) {
|
||||||
this.item = stack;
|
this.item = stack;
|
||||||
|
@ -63,7 +63,9 @@ public abstract class AReactor extends SlimefunItem {
|
|||||||
private static final int[] border_1 = {9, 10, 11, 18, 20, 27, 29, 36, 38, 45, 46, 47};
|
private static final int[] border_1 = {9, 10, 11, 18, 20, 27, 29, 36, 38, 45, 46, 47};
|
||||||
private static final int[] border_2 = {15, 16, 17, 24, 26, 33, 35, 42, 44, 51, 52, 53};
|
private static final int[] border_2 = {15, 16, 17, 24, 26, 33, 35, 42, 44, 51, 52, 53};
|
||||||
private static final int[] border_3 = {30, 31, 32, 39, 41, 48, 50};
|
private static final int[] border_3 = {30, 31, 32, 39, 41, 48, 50};
|
||||||
private static final int[] border_4 = {25, 34, 43}; // No coolant border
|
|
||||||
|
// No coolant border
|
||||||
|
private static final int[] border_4 = {25, 34, 43};
|
||||||
private static final int infoSlot = 49;
|
private static final int infoSlot = 49;
|
||||||
|
|
||||||
public AReactor(Category category, ItemStack item, String id, RecipeType recipeType, ItemStack[] recipe) {
|
public AReactor(Category category, ItemStack item, String id, RecipeType recipeType, ItemStack[] recipe) {
|
||||||
|
@ -14,14 +14,13 @@ public final class MachineHelper {
|
|||||||
|
|
||||||
private MachineHelper() {}
|
private MachineHelper() {}
|
||||||
|
|
||||||
public static String getTimeLeft(int l) {
|
public static String getTimeLeft(int seconds) {
|
||||||
String timeleft = "";
|
String timeleft = "";
|
||||||
final int minutes = (int) (l / 60L);
|
final int minutes = (int) (seconds / 60L);
|
||||||
if (minutes > 0) {
|
if (minutes > 0) {
|
||||||
timeleft = String.valueOf(timeleft) + minutes + "m ";
|
timeleft = String.valueOf(timeleft) + minutes + "m ";
|
||||||
}
|
}
|
||||||
l -= minutes * 60;
|
seconds -= minutes * 60;
|
||||||
final int seconds = (int) l;
|
|
||||||
timeleft = String.valueOf(timeleft) + seconds + "s";
|
timeleft = String.valueOf(timeleft) + seconds + "s";
|
||||||
return ChatColor.translateAlternateColorCodes('&', "&7" + timeleft + " left");
|
return ChatColor.translateAlternateColorCodes('&', "&7" + timeleft + " left");
|
||||||
}
|
}
|
||||||
|
@ -34,11 +34,12 @@ public class Composter extends SlimefunGadget {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onRightClick(ItemUseEvent e, final Player p, ItemStack item) {
|
public boolean onRightClick(ItemUseEvent e, final Player p, ItemStack item) {
|
||||||
if (e.getClickedBlock() != null) {
|
if (e.getClickedBlock() != null) {
|
||||||
SlimefunItem machine = BlockStorage.check(e.getClickedBlock());
|
String id = BlockStorage.checkID(e.getClickedBlock());
|
||||||
if (machine != null && machine.getID().equals(getID())) {
|
if (id != null && id.equals(getID())) {
|
||||||
if (CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), e.getClickedBlock(), true)) {
|
if (CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), e.getClickedBlock(), true)) {
|
||||||
final ItemStack input = p.getInventory().getItemInMainHand();
|
final ItemStack input = p.getInventory().getItemInMainHand();
|
||||||
final Block b = e.getClickedBlock();
|
final Block b = e.getClickedBlock();
|
||||||
|
SlimefunItem machine = SlimefunItem.getByID(id);
|
||||||
|
|
||||||
for (ItemStack convert: RecipeType.getRecipeInputs(machine)) {
|
for (ItemStack convert: RecipeType.getRecipeInputs(machine)) {
|
||||||
if (convert != null && SlimefunManager.isItemSimiliar(input, convert, true)) {
|
if (convert != null && SlimefunManager.isItemSimiliar(input, convert, true)) {
|
||||||
|
@ -35,11 +35,13 @@ public class Crucible extends SlimefunGadget {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onRightClick(ItemUseEvent e, final Player p, ItemStack item) {
|
public boolean onRightClick(ItemUseEvent e, final Player p, ItemStack item) {
|
||||||
if (e.getClickedBlock() != null) {
|
if (e.getClickedBlock() != null) {
|
||||||
SlimefunItem machine = BlockStorage.check(e.getClickedBlock());
|
String id = BlockStorage.checkID(e.getClickedBlock());
|
||||||
if (machine != null && machine.getID().equals("CRUCIBLE")) {
|
if (id != null && id.equals("CRUCIBLE")) {
|
||||||
if (CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), e.getClickedBlock(), true)) {
|
if (CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), e.getClickedBlock(), true)) {
|
||||||
final ItemStack input = p.getInventory().getItemInMainHand();
|
final ItemStack input = p.getInventory().getItemInMainHand();
|
||||||
final Block block = e.getClickedBlock().getRelative(BlockFace.UP);
|
final Block block = e.getClickedBlock().getRelative(BlockFace.UP);
|
||||||
|
SlimefunItem machine = SlimefunItem.getByID(id);
|
||||||
|
|
||||||
for (ItemStack convert: RecipeType.getRecipeInputs(machine)) {
|
for (ItemStack convert: RecipeType.getRecipeInputs(machine)) {
|
||||||
if (input != null && SlimefunManager.isItemSimiliar(input, convert, true)) {
|
if (input != null && SlimefunManager.isItemSimiliar(input, convert, true)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
|
@ -184,11 +184,8 @@ public class ReactorAccessPort extends SlimefunItem {
|
|||||||
public BlockMenu getReactorMenu(Location l) {
|
public BlockMenu getReactorMenu(Location l) {
|
||||||
Location reactorL = new Location(l.getWorld(), l.getX(), l.getY() - 3, l.getZ());
|
Location reactorL = new Location(l.getWorld(), l.getX(), l.getY() - 3, l.getZ());
|
||||||
|
|
||||||
String id = BlockStorage.checkID(reactorL);
|
SlimefunItem item = BlockStorage.check(reactorL.getBlock());
|
||||||
|
if (item instanceof AReactor) return BlockStorage.getInventory(l);
|
||||||
if(id.equals("NUCLEAR_REACTOR") || id.equals("NETHERSTAR_REACTOR")) {
|
|
||||||
return BlockStorage.getInventory(reactorL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,7 @@ package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -22,7 +20,6 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler;
|
|||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.UnregisterReason;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.UnregisterReason;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe;
|
|
||||||
import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;
|
import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;
|
||||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||||
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
|
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
|
||||||
@ -32,11 +29,6 @@ import me.mrCookieSlime.Slimefun.api.item_transport.RecipeSorter;
|
|||||||
|
|
||||||
public abstract class ElectricSmeltery extends AContainer {
|
public abstract class ElectricSmeltery extends AContainer {
|
||||||
|
|
||||||
public static Map<Block, MachineRecipe> processing = new HashMap<>();
|
|
||||||
public static Map<Block, Integer> progress = new HashMap<>();
|
|
||||||
|
|
||||||
protected List<MachineRecipe> recipes = new ArrayList<>();
|
|
||||||
|
|
||||||
private static final int[] border = {4, 5, 6, 7, 8, 13, 31, 40, 41, 42, 43, 44};
|
private static final int[] border = {4, 5, 6, 7, 8, 13, 31, 40, 41, 42, 43, 44};
|
||||||
private static final int[] border_in = {0, 1, 2, 3, 9, 12, 18, 21, 27, 30, 36, 37, 38, 39};
|
private static final int[] border_in = {0, 1, 2, 3, 9, 12, 18, 21, 27, 30, 36, 37, 38, 39};
|
||||||
private static final int[] border_out = {14, 15, 16, 17, 23, 26, 32, 33, 34, 35};
|
private static final int[] border_out = {14, 15, 16, 17, 23, 26, 32, 33, 34, 35};
|
||||||
|
@ -2718,8 +2718,8 @@ public final class SlimefunSetup {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onRightClick(ItemUseEvent e, Player p, ItemStack stack) {
|
public boolean onRightClick(ItemUseEvent e, Player p, ItemStack stack) {
|
||||||
if (e.getClickedBlock() == null) return false;
|
if (e.getClickedBlock() == null) return false;
|
||||||
SlimefunItem item = BlockStorage.check(e.getClickedBlock());
|
String item = BlockStorage.checkID(e.getClickedBlock());
|
||||||
if (item == null || !item.getID().equals("GPS_CONTROL_PANEL")) return false;
|
if (item == null || !item.equals("GPS_CONTROL_PANEL")) return false;
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
|
|
||||||
Slimefun.getGPSNetwork().openTransmitterControlPanel(p);
|
Slimefun.getGPSNetwork().openTransmitterControlPanel(p);
|
||||||
@ -3137,8 +3137,8 @@ public final class SlimefunSetup {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onRightClick(ItemUseEvent e, Player p, ItemStack stack) {
|
public boolean onRightClick(ItemUseEvent e, Player p, ItemStack stack) {
|
||||||
if (e.getClickedBlock() == null) return false;
|
if (e.getClickedBlock() == null) return false;
|
||||||
SlimefunItem item = BlockStorage.check(e.getClickedBlock());
|
String item = BlockStorage.checkID(e.getClickedBlock());
|
||||||
if (item == null || !item.getID().equals("GPS_GEO_SCANNER")) return false;
|
if (item == null || !item.equals("GPS_GEO_SCANNER")) return false;
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
|
|
||||||
Slimefun.getGPSNetwork().scanChunk(p, e.getClickedBlock().getChunk());
|
Slimefun.getGPSNetwork().scanChunk(p, e.getClickedBlock().getChunk());
|
||||||
@ -3316,9 +3316,8 @@ public final class SlimefunSetup {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onRightClick(final ItemUseEvent e, Player p, ItemStack stack) {
|
public boolean onRightClick(final ItemUseEvent e, Player p, ItemStack stack) {
|
||||||
if (e.getClickedBlock() == null) return false;
|
if (e.getClickedBlock() == null) return false;
|
||||||
SlimefunItem item = BlockStorage.check(e.getClickedBlock());
|
String item = BlockStorage.checkID(e.getClickedBlock());
|
||||||
if (item == null) return false;
|
if (item == null || !item.equals("ELEVATOR_PLATE")) return false;
|
||||||
if (!item.getID().equals("ELEVATOR_PLATE")) return false;
|
|
||||||
|
|
||||||
if (BlockStorage.getLocationInfo(e.getClickedBlock().getLocation(), "owner").equals(p.getUniqueId().toString())) Elevator.openEditor(p, e.getClickedBlock());
|
if (BlockStorage.getLocationInfo(e.getClickedBlock().getLocation(), "owner").equals(p.getUniqueId().toString())) Elevator.openEditor(p, e.getClickedBlock());
|
||||||
return true;
|
return true;
|
||||||
@ -3732,8 +3731,8 @@ public final class SlimefunSetup {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onRightClick(ItemUseEvent e, Player p, ItemStack stack) {
|
public boolean onRightClick(ItemUseEvent e, Player p, ItemStack stack) {
|
||||||
if (e.getClickedBlock() == null) return false;
|
if (e.getClickedBlock() == null) return false;
|
||||||
SlimefunItem item = BlockStorage.check(e.getClickedBlock());
|
String item = BlockStorage.checkID(e.getClickedBlock());
|
||||||
if (item == null || !item.getID().equals("CARGO_MANAGER")) return false;
|
if (item == null || !item.equals("CARGO_MANAGER")) return false;
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
|
|
||||||
if (BlockStorage.getLocationInfo(e.getClickedBlock().getLocation(), "visualizer") == null) {
|
if (BlockStorage.getLocationInfo(e.getClickedBlock().getLocation(), "visualizer") == null) {
|
||||||
|
@ -1026,14 +1026,13 @@ public final class SlimefunGuide {
|
|||||||
getHistory().remove(uuid);
|
getHistory().remove(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getTimeLeft(int l) {
|
private static String getTimeLeft(int seconds) {
|
||||||
String timeleft = "";
|
String timeleft = "";
|
||||||
final int minutes = (int) (l / 60L);
|
final int minutes = (int) (seconds / 60L);
|
||||||
if (minutes > 0) {
|
if (minutes > 0) {
|
||||||
timeleft = String.valueOf(timeleft) + minutes + "m ";
|
timeleft = String.valueOf(timeleft) + minutes + "m ";
|
||||||
}
|
}
|
||||||
l -= minutes * 60;
|
seconds -= minutes * 60;
|
||||||
final int seconds = (int)l;
|
|
||||||
timeleft = String.valueOf(timeleft) + seconds + "s";
|
timeleft = String.valueOf(timeleft) + seconds + "s";
|
||||||
return "&7" + timeleft;
|
return "&7" + timeleft;
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,6 @@ import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
|||||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Player.PlayerInventory;
|
import me.mrCookieSlime.CSCoreLibPlugin.general.Player.PlayerInventory;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.general.String.StringUtils;
|
import me.mrCookieSlime.CSCoreLibPlugin.general.String.StringUtils;
|
||||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
|
||||||
import me.mrCookieSlime.Slimefun.Setup.Messages;
|
import me.mrCookieSlime.Slimefun.Setup.Messages;
|
||||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||||
import me.mrCookieSlime.Slimefun.utils.Utilities;
|
import me.mrCookieSlime.Slimefun.utils.Utilities;
|
||||||
@ -52,9 +51,9 @@ public class AncientAltarListener implements Listener {
|
|||||||
public void onInteract(PlayerInteractEvent e) {
|
public void onInteract(PlayerInteractEvent e) {
|
||||||
if (e.getAction() != Action.RIGHT_CLICK_BLOCK) return;
|
if (e.getAction() != Action.RIGHT_CLICK_BLOCK) return;
|
||||||
Block b = e.getClickedBlock();
|
Block b = e.getClickedBlock();
|
||||||
SlimefunItem item = BlockStorage.check(b);
|
String item = BlockStorage.checkID(b);
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
if (item.getID().equals("ANCIENT_PEDESTAL")) {
|
if (item.equals("ANCIENT_PEDESTAL")) {
|
||||||
if (utilities.altarinuse.contains(b.getLocation())) {
|
if (utilities.altarinuse.contains(b.getLocation())) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -81,7 +80,7 @@ public class AncientAltarListener implements Listener {
|
|||||||
PlayerInventory.update(e.getPlayer());
|
PlayerInventory.update(e.getPlayer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (item.getID().equals("ANCIENT_ALTAR")) {
|
else if (item.equals("ANCIENT_ALTAR")) {
|
||||||
if (utilities.altarinuse.contains(b.getLocation())) {
|
if (utilities.altarinuse.contains(b.getLocation())) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -185,9 +184,9 @@ public class AncientAltarListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onBlockPlace(BlockPlaceEvent e) {
|
public void onBlockPlace(BlockPlaceEvent e) {
|
||||||
Block b = e.getBlockPlaced().getRelative(0, -1, 0);
|
Block b = e.getBlockPlaced().getRelative(0, -1, 0);
|
||||||
SlimefunItem item = BlockStorage.check(b);
|
String item = BlockStorage.checkID(b);
|
||||||
if(item == null) return;
|
|
||||||
if(item.getID().equalsIgnoreCase("ANCIENT_PEDESTAL")) {
|
if (item != null && item.equalsIgnoreCase("ANCIENT_PEDESTAL")) {
|
||||||
Messages.local.sendTranslation(e.getPlayer(), "messages.cannot-place", true);
|
Messages.local.sendTranslation(e.getPlayer(), "messages.cannot-place", true);
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
@ -498,7 +498,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
|
|||||||
private void mine(Block b, Block block) {
|
private void mine(Block b, Block block) {
|
||||||
Collection<ItemStack> drops = block.getDrops();
|
Collection<ItemStack> drops = block.getDrops();
|
||||||
if (!blockblacklist.contains(block.getType()) && !drops.isEmpty() && CSCoreLib.getLib().getProtectionManager().canBuild(UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner")), block)) {
|
if (!blockblacklist.contains(block.getType()) && !drops.isEmpty() && CSCoreLib.getLib().getProtectionManager().canBuild(UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner")), block)) {
|
||||||
SlimefunItem item = BlockStorage.check(block);
|
String item = BlockStorage.checkID(block);
|
||||||
|
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
ItemStack[] items = drops.toArray(new ItemStack[drops.size()]);
|
ItemStack[] items = drops.toArray(new ItemStack[drops.size()]);
|
||||||
|
@ -8,7 +8,7 @@ import me.mrCookieSlime.CSCoreLibPlugin.PlayerRunnable;
|
|||||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
|
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
|
||||||
import me.mrCookieSlime.Slimefun.SlimefunGuide;
|
import me.mrCookieSlime.Slimefun.SlimefunGuide;
|
||||||
|
|
||||||
public abstract class GuideHandler {
|
public interface GuideHandler {
|
||||||
|
|
||||||
public abstract void addEntry(List<String> texts, List<String> tooltips);
|
public abstract void addEntry(List<String> texts, List<String> tooltips);
|
||||||
public abstract PlayerRunnable getRunnable();
|
public abstract PlayerRunnable getRunnable();
|
||||||
@ -17,11 +17,11 @@ public abstract class GuideHandler {
|
|||||||
|
|
||||||
public abstract int next(Player p, int index, ChestMenu menu);
|
public abstract int next(Player p, int index, ChestMenu menu);
|
||||||
|
|
||||||
public PlayerRunnable getRunnable(boolean book) {
|
default PlayerRunnable getRunnable(boolean book) {
|
||||||
return this.getRunnable();
|
return this.getRunnable();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(Player p, boolean survival, boolean book) {
|
default void run(Player p, boolean survival, boolean book) {
|
||||||
this.getRunnable(book).run(p);
|
this.getRunnable(book).run(p);
|
||||||
|
|
||||||
if (survival && this.trackHistory()) {
|
if (survival && this.trackHistory()) {
|
||||||
|
@ -15,7 +15,7 @@ import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
|
|||||||
|
|
||||||
public abstract class BlockMenuPreset extends ChestMenu {
|
public abstract class BlockMenuPreset extends ChestMenu {
|
||||||
|
|
||||||
private String title;
|
private String inventoryTitle;
|
||||||
private Set<Integer> occupied = new HashSet<>();
|
private Set<Integer> occupied = new HashSet<>();
|
||||||
private String id;
|
private String id;
|
||||||
private int size = -1;
|
private int size = -1;
|
||||||
@ -23,10 +23,10 @@ public abstract class BlockMenuPreset extends ChestMenu {
|
|||||||
|
|
||||||
private ItemManipulationEvent event;
|
private ItemManipulationEvent event;
|
||||||
|
|
||||||
public BlockMenuPreset(String id, String title) {
|
public BlockMenuPreset(String id, String inventoryTitle) {
|
||||||
super(title);
|
super(inventoryTitle);
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.title = title;
|
this.inventoryTitle = inventoryTitle;
|
||||||
this.init();
|
this.init();
|
||||||
this.universal = false;
|
this.universal = false;
|
||||||
SlimefunPlugin.getUtilities().blockMenuPresets.put(id, this);
|
SlimefunPlugin.getUtilities().blockMenuPresets.put(id, this);
|
||||||
@ -36,10 +36,10 @@ public abstract class BlockMenuPreset extends ChestMenu {
|
|||||||
this.event = event;
|
this.event = event;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockMenuPreset(String id, String title, boolean universal) {
|
public BlockMenuPreset(String id, String inventoryTitle, boolean universal) {
|
||||||
super(title);
|
super(inventoryTitle);
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.title = title;
|
this.inventoryTitle = inventoryTitle;
|
||||||
this.init();
|
this.init();
|
||||||
this.universal = universal;
|
this.universal = universal;
|
||||||
SlimefunPlugin.getUtilities().blockMenuPresets.put(id, this);
|
SlimefunPlugin.getUtilities().blockMenuPresets.put(id, this);
|
||||||
@ -74,11 +74,11 @@ public abstract class BlockMenuPreset extends ChestMenu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getSize() {
|
public int getSize() {
|
||||||
return this.size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
return this.title;
|
return inventoryTitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Integer> getPresetSlots() {
|
public Set<Integer> getPresetSlots() {
|
||||||
|
@ -75,14 +75,14 @@ public abstract class GitHubConnector {
|
|||||||
|
|
||||||
public void parseData() {
|
public void parseData() {
|
||||||
try (BufferedReader reader = new BufferedReader(new FileReader(this.getFile()))) {
|
try (BufferedReader reader = new BufferedReader(new FileReader(this.getFile()))) {
|
||||||
String full = "";
|
StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
String line;
|
String line;
|
||||||
while ((line = reader.readLine()) != null) {
|
while ((line = reader.readLine()) != null) {
|
||||||
full = full + line;
|
builder.append(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonElement element = new JsonParser().parse(full);
|
JsonElement element = new JsonParser().parse(builder.toString());
|
||||||
this.onSuccess(element);
|
this.onSuccess(element);
|
||||||
}
|
}
|
||||||
catch (IOException x) {
|
catch (IOException x) {
|
||||||
|
@ -71,8 +71,9 @@ public class DamageListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.getEntity().getKiller() instanceof Player) {
|
if (e.getEntity().getKiller() instanceof Player) {
|
||||||
Player p = (Player) e.getEntity().getKiller();
|
Player p = e.getEntity().getKiller();
|
||||||
ItemStack item = p.getInventory().getItemInMainHand();
|
ItemStack item = p.getInventory().getItemInMainHand();
|
||||||
|
|
||||||
if (SlimefunPlugin.getUtilities().drops.containsKey(e.getEntity().getType())) {
|
if (SlimefunPlugin.getUtilities().drops.containsKey(e.getEntity().getType())) {
|
||||||
|
@ -251,13 +251,15 @@ public class ToolListener implements Listener {
|
|||||||
|
|
||||||
while (blocks.hasNext()) {
|
while (blocks.hasNext()) {
|
||||||
Block block = blocks.next();
|
Block block = blocks.next();
|
||||||
SlimefunItem item = BlockStorage.check(block);
|
String id = BlockStorage.checkID(block);
|
||||||
if (item != null) {
|
if (id != null) {
|
||||||
blocks.remove();
|
blocks.remove();
|
||||||
if (!item.getID().equalsIgnoreCase("HARDENED_GLASS") && !item.getID().equalsIgnoreCase("WITHER_PROOF_OBSIDIAN") && !item.getID().equalsIgnoreCase("WITHER_PROOF_GLASS") && !item.getID().equalsIgnoreCase("FORCEFIELD_PROJECTOR") && !item.getID().equalsIgnoreCase("FORCEFIELD_RELAY")) {
|
if (!id.equalsIgnoreCase("HARDENED_GLASS") && !id.equalsIgnoreCase("WITHER_PROOF_OBSIDIAN") && !id.equalsIgnoreCase("WITHER_PROOF_GLASS") && !id.equalsIgnoreCase("FORCEFIELD_PROJECTOR") && !id.equalsIgnoreCase("FORCEFIELD_RELAY")) {
|
||||||
boolean success = true;
|
boolean success = true;
|
||||||
if (utilities.blockHandlers.containsKey(item.getID())) {
|
SlimefunItem item = SlimefunItem.getByID(id);
|
||||||
success = utilities.blockHandlers.get(item.getID()).onBreak(null, block, item, UnregisterReason.EXPLODE);
|
|
||||||
|
if (utilities.blockHandlers.containsKey(id)) {
|
||||||
|
success = utilities.blockHandlers.get(id).onBreak(null, block, item, UnregisterReason.EXPLODE);
|
||||||
}
|
}
|
||||||
if (success) {
|
if (success) {
|
||||||
BlockStorage.clearBlockInfo(block);
|
BlockStorage.clearBlockInfo(block);
|
||||||
|
Loading…
Reference in New Issue
Block a user