1212import io .github .thebusybiscuit .slimefun4 .implementation .handlers .SimpleBlockBreakHandler ;
1313import io .github .thebusybiscuit .slimefun4 .libraries .dough .skins .PlayerHead ;
1414import io .github .thebusybiscuit .slimefun4 .libraries .dough .skins .PlayerSkin ;
15+ import lombok .Getter ;
1516import me .mrCookieSlime .CSCoreLibPlugin .Configuration .Config ;
1617import me .mrCookieSlime .Slimefun .Objects .handlers .BlockTicker ;
1718import me .mrCookieSlime .Slimefun .api .BlockStorage ;
1819import me .pranavverma .advancedtech .general .BaseItems ;
1920import me .pranavverma .advancedtech .general .items .solargen .AdvancedSolarGen .AdvancedSolarGen ;
21+ import net .guizhanss .guizhanlib .slimefun .machines .TickingMenuBlock ;
2022import me .pranavverma .advancedtech .AdvancedTech ;
2123import org .bukkit .ChatColor ;
2224import org .bukkit .Material ;
3739import org .bukkit .event .Listener ;
3840import org .bukkit .event .Event .Result ;
3941import org .bukkit .plugin .java .JavaPlugin ;
40-
42+ import java .util .HashMap ;
43+ import java .util .Map ;
4144import org .bukkit .Location ;
42- import org .bukkit .Material ;
43- import org .bukkit .block .Block ;
44- import org .bukkit .entity .Entity ;
45- import org .bukkit .entity .EntityType ;
46- import org .bukkit .entity .Player ;
47- import org .bukkit .event .block .BlockPlaceEvent ;
48- import org .bukkit .inventory .ItemStack ;
45+
4946
5047import io .github .thebusybiscuit .slimefun4 .api .items .ItemGroup ;
51- import io .github .thebusybiscuit .slimefun4 .api .items .SlimefunItem ;
5248import io .github .thebusybiscuit .slimefun4 .api .items .SlimefunItemStack ;
5349import io .github .thebusybiscuit .slimefun4 .api .recipes .RecipeType ;
54- import io .github .thebusybiscuit .slimefun4 .api .researches .Research ;
55- import io .github .thebusybiscuit .slimefun4 .core .attributes .EnergyNetComponent ;
5650import io .github .thebusybiscuit .slimefun4 .core .handlers .BlockPlaceHandler ;
57- import io .github .thebusybiscuit .slimefun4 .core .networks .energy .EnergyNetComponentType ;
58- import io .github .thebusybiscuit .slimefun4 .implementation .SlimefunItems ;
59- import io .github .thebusybiscuit .slimefun4 .implementation .items .SimpleSlimefunItem ;
60- import io .github .thebusybiscuit .slimefun4 .implementation .items .food .MeatJerky ;
61- import io .github .thebusybiscuit .slimefun4 .libraries .dough .items .CustomItemStack ;
62- import io .github .thebusybiscuit .slimefun4 .utils .ChatUtils ;
63- import me .mrCookieSlime .CSCoreLibPlugin .Configuration .Config ;
64- import me .mrCookieSlime .Slimefun .Objects .handlers .BlockTicker ;
6551import me .mrCookieSlime .Slimefun .api .BlockStorage ;
6652import me .mrCookieSlime .Slimefun .api .inventory .BlockMenu ;
6753import me .mrCookieSlime .Slimefun .api .inventory .BlockMenuPreset ;
68- import me .mrCookieSlime .Slimefun .api .item_transport .ItemTransportFlow ;
54+ import org .bukkit .Location ;
55+ import org .bukkit .block .Block ;
56+ import org .bukkit .event .block .BlockBreakEvent ;
57+ import org .bukkit .event .block .BlockPlaceEvent ;
58+ import org .bukkit .inventory .ItemStack ;
6959
70- import io .github .thebusybiscuit .slimefun4 .libraries .dough .items .CustomItemStack ;
71- import io .github .thebusybiscuit .slimefun4 .utils .ChatUtils ;
72- import io .github .thebusybiscuit .slimefun4 .utils .ChestMenuUtils ;
73- import lombok .AccessLevel ;
74- import lombok .Setter ;
75- import me .mrCookieSlime .CSCoreLibPlugin .general .Inventory .ChestMenu ;
60+ import javax .annotation .ParametersAreNonnullByDefault ;
7661
7762
7863public class command_hub extends SlimefunItem implements HologramOwner , Listener {
7964
8065 public static boolean readyToUse = false ;
81- public static boolean AdvancedSolarGenFound = false ;
82- public static boolean onCommandHubRemoval = false ;
66+ //Done
67+ private boolean AdvancedSolarGenFound = false ;
68+
69+ protected static final Map <Location , Object > CACHES = new HashMap <>();
8370
8471
8572 public command_hub (ItemGroup itemGroup , SlimefunItemStack item , RecipeType recipeType , ItemStack [] recipe ) {
8673 super (itemGroup , item , recipeType , recipe );
74+
8775
8876 addItemHandler (onBreak ());
8977 addItemHandler (onPlace ());
@@ -92,7 +80,7 @@ public command_hub(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recip
9280 public boolean isSynchronized () {
9381 return true ;
9482 }
95-
83+
9684 @ Override
9785 public void tick (Block block , SlimefunItem slimefunItem , Config config ) {
9886 if (scanForCommandEngine (block )) {
@@ -106,6 +94,8 @@ public void tick(Block block, SlimefunItem slimefunItem, Config config) {
10694
10795 if (scanForAdvancedSolarGen (block )) {
10896 AdvancedSolarGenFound = true ;
97+
98+
10999 } else {
110100 AdvancedSolarGenFound = false ;
111101 }
@@ -120,7 +110,6 @@ public void preRegister() {
120110 addItemHandler (blockUseHandler );
121111
122112 }
123-
124113
125114
126115
@@ -132,7 +121,6 @@ private BlockBreakHandler onBreak() {
132121 @ Override
133122 public void onBlockBreak (@ Nonnull Block b ) {
134123 removeHologram (b );
135- onCommandHubRemoval = true ;
136124 }
137125 };
138126 }
@@ -188,7 +176,6 @@ private boolean scanForAdvancedSolarGen (@Nonnull Block block){
188176
189177 @ Nonnull
190178 private BlockPlaceHandler onPlace () {
191- onCommandHubRemoval = false ;
192179
193180 return new BlockPlaceHandler (true ) {
194181 @ Override
@@ -265,7 +252,24 @@ public void onInventoryClick(InventoryClickEvent event) {
265252 HumanEntity human = event .getWhoClicked ();
266253 Inventory inventory = event .getClickedInventory ();
267254
268- if (human instanceof Player && inventory != null && inventory .getSize () == 9 && inventory .getItem (0 ).hasItemMeta ()) {
255+ if (human instanceof Player && inventory != null && inventory .getSize () == 9 && inventory .getItem (0 ).hasItemMeta () && inventory .getItem (8 ).getType () == Material .BLACK_STAINED_GLASS && inventory .getItem (7 ).getType () == Material .BLACK_STAINED_GLASS && inventory .getItem (6 ).getType () == Material .BLACK_STAINED_GLASS ) {
256+ if (inventory .getItem (0 ) == null ) {
257+
258+ }
259+
260+ if (inventory .getItem (6 ) == null ) {
261+
262+ }
263+
264+ if (inventory .getItem (7 ) == null ) {
265+
266+ }
267+
268+ if (inventory .getItem (8 ) == null ) {
269+
270+ }
271+
272+
269273 event .setResult (Result .DENY ); // Cancel the click event
270274 event .setCancelled (true );
271275
@@ -279,7 +283,7 @@ public void onInventoryDrag(InventoryDragEvent event) {
279283
280284
281285
282- if (human instanceof Player && inventory != null && inventory .getSize () == 9 && inventory .getItem (0 ).hasItemMeta ()) {
286+ if (human instanceof Player && inventory != null && inventory .getSize () == 9 && inventory .getItem (0 ).hasItemMeta () && inventory . getItem ( 8 ). getType () == Material . BLACK_STAINED_GLASS && inventory . getItem ( 7 ). getType () == Material . BLACK_STAINED_GLASS && inventory . getItem ( 6 ). getType () == Material . BLACK_STAINED_GLASS ) {
283287 event .setCancelled (true ); // Cancel the drag event
284288 }
285289 }
0 commit comments