aboutsummaryrefslogtreecommitdiff
path: root/features/betterGuis/museumGui.js
blob: 06497af9372121770526bc20509d509ee8574d81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
import { SoopyGui, SoopyRenderEvent } from "../../../guimanager"
import SoopyContentChangeEvent from "../../../guimanager/EventListener/SoopyContentChangeEvent"
import SoopyHoverChangeEvent from "../../../guimanager/EventListener/SoopyHoverChangeEvent"
import SoopyKeyPressEvent from "../../../guimanager/EventListener/SoopyKeyPressEvent"
import SoopyMouseClickEvent from "../../../guimanager/EventListener/SoopyMouseClickEvent"
import SoopyOpenGuiEvent from "../../../guimanager/EventListener/SoopyOpenGuiEvent"
import BoxWithText from "../../../guimanager/GuiElement/BoxWithText"
import ButtonWithArrow from "../../../guimanager/GuiElement/ButtonWithArrow"
import ProgressBar from "../../../guimanager/GuiElement/ProgressBar"
import SoopyBoxElement from "../../../guimanager/GuiElement/SoopyBoxElement"
import SoopyGuiElement from "../../../guimanager/GuiElement/SoopyGuiElement"
import SoopyMarkdownElement from "../../../guimanager/GuiElement/SoopyMarkdownElement"
import SoopyTextElement from "../../../guimanager/GuiElement/SoopyTextElement"
import TextBox from "../../../guimanager/GuiElement/TextBox"
import Notification from "../../../guimanager/Notification"
import renderLibs from "../../../guimanager/renderLibs"
import { m } from "../../../mappings/mappings"
import * as utils from "../../utils/utils"


const ContainerChest = Java.type("net.minecraft.inventory.ContainerChest")

class MuseumGui {
    constructor() {
        this.checkMenu = false

        this.isInMuseum = false
        this.guiOpenTickThing = false
        this.dontOpen = 0
        this.lastClosed = 0
        this.itemsInPages = JSON.parse(FileLib.read("soopyAddonsData", "museumItemsCache.json") || "{}") || {}
        this.itemsInPagesSaved = true

        this.soopyGui = new SoopyGui()

        this.soopyGui.optimisedLocations = true

        this.soopyGui.element.addEvent(new SoopyKeyPressEvent().setHandler((...args) => {
            this.keyPress(...args)
        }))

        this.mainPage = new SoopyGuiElement().setLocation(0, 0, 1, 1)
        this.soopyGui.element.addChild(this.mainPage)

        let widthPer = 0.2
        let leftOffset = (1 - widthPer * 3 - widthPer * 4 / 5) / 2

        this.weaponsIndicator = new SoopyBoxElement().setLocation(leftOffset, 0.05, widthPer * 4 / 5, 0.15)
        this.weaponsIndicator.addEvent(new SoopyRenderEvent().setHandler(() => {
            if (this.weaponsIndicator.hovered && ChatLib.removeFormatting(Player.getContainer().getStackInSlot(4).getName()) !== "Weapons") {
                this.weaponText.location.location.x.set(0.05, 500)
                this.weaponText.location.size.x.set(0.9, 500)
                this.weaponText.location.location.y.set(0.025, 500)
                this.weaponText.location.size.y.set(0.35, 500)

                this.weaponsIndicator.setColorOffset(-20, -20, -20, 100)

                Renderer.translate(0, 0, 100)
                Renderer.drawRect(Renderer.color(0, 0, 0, 100), this.weaponsIndicator.location.getXExact(), this.weaponsIndicator.location.getYExact(), this.weaponsIndicator.location.getWidthExact(), this.weaponsIndicator.location.getHeightExact())
                let clicks = Player.getContainer().getName() === "Your Museum" ? "1" : "2"
                Renderer.translate(0, 0, 100)
                renderLibs.drawStringCenteredFull(clicks, this.weaponsIndicator.location.getXExact() + this.weaponsIndicator.location.getWidthExact() / 2, this.weaponsIndicator.location.getYExact() + this.weaponsIndicator.location.getHeightExact() / 2, Math.min(this.weaponsIndicator.location.getWidthExact() / Renderer.getStringWidth(clicks) / 4, this.weaponsIndicator.location.getHeightExact() / 4 / 2))
            } else {
                this.weaponText.location.location.x.set(0.1, 500)
                this.weaponText.location.size.x.set(0.8, 500)
                this.weaponText.location.location.y.set(0.05, 500)
                this.weaponText.location.size.y.set(0.3, 500)

                this.weaponsIndicator.setColorOffset(0, 0, 0, 100)
            }
        })).addEvent(new SoopyMouseClickEvent().setHandler(() => {
            this.clickedTopButton("Weapons")
        }))

        this.weaponText = new SoopyTextElement().setText("§5Weapons").setMaxTextScale(10).setLocation(0.1, 0.05, 0.8, 0.3)
        this.weaponsIndicator.addChild(this.weaponText)
        this.weaponsPercentageText = new SoopyTextElement().setLocation(0.1, 0.4, 0.8, 0.2).setText("§0Items Donated: §7Loading...").setMaxTextScale(10)
        this.weaponsIndicator.addChild(this.weaponsPercentageText)
        this.weaponsProgressBar = new ProgressBar().setLocation(0.1, 0.6, 0.8, 0.35).showPercentage(true)
        this.weaponsIndicator.addChild(this.weaponsProgressBar)
        this.mainPage.addChild(this.weaponsIndicator)

        this.armourIndicator = new SoopyBoxElement().setLocation(leftOffset + widthPer, 0.05, widthPer * 4 / 5, 0.15)
        this.armourIndicator.addEvent(new SoopyRenderEvent().setHandler(() => {
            if (this.armourIndicator.hovered && ChatLib.removeFormatting(Player.getContainer().getStackInSlot(4).getName()) !== "Armor Sets") {
                this.armourText.location.location.x.set(0.05, 500)
                this.armourText.location.size.x.set(0.9, 500)
                this.armourText.location.location.y.set(0.025, 500)
                this.armourText.location.size.y.set(0.35, 500)

                this.armourIndicator.setColorOffset(-20, -20, -20, 100)

                Renderer.translate(0, 0, 100)
                Renderer.drawRect(Renderer.color(0, 0, 0, 100), this.armourIndicator.location.getXExact(), this.armourIndicator.location.getYExact(), this.armourIndicator.location.getWidthExact(), this.armourIndicator.location.getHeightExact())
                let clicks = Player.getContainer().getName() === "Your Museum" ? "1" : "2"
                Renderer.translate(0, 0, 100)
                renderLibs.drawStringCenteredFull(clicks, this.armourIndicator.location.getXExact() + this.armourIndicator.location.getWidthExact() / 2, this.armourIndicator.location.getYExact() + this.armourIndicator.location.getHeightExact() / 2, Math.min(this.armourIndicator.location.getWidthExact() / Renderer.getStringWidth(clicks) / 4, this.armourIndicator.location.getHeightExact() / 4 / 2))
            } else {
                this.armourText.location.location.x.set(0.1, 500)
                this.armourText.location.size.x.set(0.8, 500)
                this.armourText.location.location.y.set(0.05, 500)
                this.armourText.location.size.y.set(0.3, 500)

                this.armourIndicator.setColorOffset(0, 0, 0, 100)
            }
        })).addEvent(new SoopyMouseClickEvent().setHandler(() => {
            this.clickedTopButton("Armor Sets")
        }))

        this.armourText = new SoopyTextElement().setText("§5Armor Sets").setMaxTextScale(10).setLocation(0.1, 0.05, 0.8, 0.3)
        this.armourIndicator.addChild(this.armourText)
        this.armourPercentageText = new SoopyTextElement().setLocation(0.1, 0.4, 0.8, 0.2).setText("§0Items Donated: §7Loading...").setMaxTextScale(10)
        this.armourIndicator.addChild(this.armourPercentageText)
        this.armourProgressBar = new ProgressBar().setLocation(0.1, 0.6, 0.8, 0.35).showPercentage(true)
        this.armourIndicator.addChild(this.armourProgressBar)
        this.mainPage.addChild(this.armourIndicator)

        this.raritiesIndicator = new SoopyBoxElement().setLocation(leftOffset + widthPer * 2, 0.05, widthPer * 4 / 5, 0.15)
        this.raritiesIndicator.addEvent(new SoopyRenderEvent().setHandler(() => {
            if (this.raritiesIndicator.hovered && ChatLib.removeFormatting(Player.getContainer().getStackInSlot(4).getName()) !== "Rarities") {
                this.raritiesText.location.location.x.set(0.05, 500)
                this.raritiesText.location.size.x.set(0.9, 500)
                this.raritiesText.location.location.y.set(0.025, 500)
                this.raritiesText.location.size.y.set(0.35, 500)

                this.raritiesIndicator.setColorOffset(-20, -20, -20, 100)

                Renderer.translate(0, 0, 100)
                Renderer.drawRect(Renderer.color(0, 0, 0, 100), this.raritiesIndicator.location.getXExact(), this.raritiesIndicator.location.getYExact(), this.raritiesIndicator.location.getWidthExact(), this.raritiesIndicator.location.getHeightExact())
                let clicks = Player.getContainer().getName() === "Your Museum" ? "1" : "2"
                Renderer.translate(0, 0, 100)
                renderLibs.drawStringCenteredFull(clicks, this.raritiesIndicator.location.getXExact() + this.raritiesIndicator.location.getWidthExact() / 2, this.raritiesIndicator.location.getYExact() + this.raritiesIndicator.location.getHeightExact() / 2, Math.min(this.raritiesIndicator.location.getWidthExact() / Renderer.getStringWidth(clicks) / 4, this.raritiesIndicator.location.getHeightExact() / 4 / 2))
            } else {
                this.raritiesText.location.location.x.set(0.1, 500)
                this.raritiesText.location.size.x.set(0.8, 500)
                this.raritiesText.location.location.y.set(0.05, 500)
                this.raritiesText.location.size.y.set(0.3, 500)

                this.raritiesIndicator.setColorOffset(0, 0, 0, 100)
            }
        })).addEvent(new SoopyMouseClickEvent().setHandler(() => {
            this.clickedTopButton("Rarities")
        }))

        this.raritiesText = new SoopyTextElement().setText("§5Rarities").setMaxTextScale(10).setLocation(0.1, 0.05, 0.8, 0.3)
        this.raritiesIndicator.addChild(this.raritiesText)
        this.raritiesPercentageText = new SoopyTextElement().setLocation(0.1, 0.4, 0.8, 0.2).setText("§0Items Donated: §7Loading...").setMaxTextScale(10)
        this.raritiesIndicator.addChild(this.raritiesPercentageText)
        this.raritiesProgressBar = new ProgressBar().setLocation(0.1, 0.6, 0.8, 0.35).showPercentage(true)
        this.raritiesIndicator.addChild(this.raritiesProgressBar)
        this.mainPage.addChild(this.raritiesIndicator)

        this.specialIndicator = new SoopyBoxElement().setLocation(leftOffset + widthPer * 3, 0.05, widthPer * 4 / 5, 0.15)
        this.specialIndicator.addEvent(new SoopyRenderEvent().setHandler(() => {
            if (this.specialIndicator.hovered && ChatLib.removeFormatting(Player.getContainer().getStackInSlot(4).getName()) !== "Special Items") {
                this.specialText.location.location.x.set(0.05, 500)
                this.specialText.location.size.x.set(0.9, 500)
                this.specialText.location.location.y.set(0.025, 500)
                this.specialText.location.size.y.set(0.35, 500)

                this.specialIndicator.setColorOffset(-20, -20, -20, 100)

                Renderer.translate(0, 0, 100)
                Renderer.drawRect(Renderer.color(0, 0, 0, 100), this.specialIndicator.location.getXExact(), this.specialIndicator.location.getYExact(), this.specialIndicator.location.getWidthExact(), this.specialIndicator.location.getHeightExact())
                let clicks = Player.getContainer().getName() === "Your Museum" ? "1" : "2"
                Renderer.translate(0, 0, 100)
                renderLibs.drawStringCenteredFull(clicks, this.specialIndicator.location.getXExact() + this.specialIndicator.location.getWidthExact() / 2, this.specialIndicator.location.getYExact() + this.specialIndicator.location.getHeightExact() / 2, Math.min(this.specialIndicator.location.getWidthExact() / Renderer.getStringWidth(clicks) / 4, this.specialIndicator.location.getHeightExact() / 4 / 2))

            } else {
                this.specialText.location.location.x.set(0.1, 500)
                this.specialText.location.size.x.set(0.8, 500)
                this.specialText.location.location.y.set(0.05, 500)
                this.specialText.location.size.y.set(0.3, 500)

                this.specialIndicator.setColorOffset(0, 0, 0, 100)
            }
        })).addEvent(new SoopyMouseClickEvent().setHandler(() => {
            this.clickedTopButton("Special Items")
        }))

        this.specialText = new SoopyTextElement().setText("§5Special Items").setMaxTextScale(10).setLocation(0.1, 0.05, 0.8, 0.3)
        this.specialIndicator.addChild(this.specialText)
        this.specialPercentageText = new SoopyTextElement().setLocation(0.1, 0.4, 0.8, 0.6).setText("§0Items Donated: §7Loading...").setMaxTextScale(10)
        this.specialIndicator.addChild(this.specialPercentageText)
        this.mainPage.addChild(this.specialIndicator)

        let box = new SoopyBoxElement().setLocation(0.5 - widthPer * 0.75, 0.25, widthPer * 2 * 0.75, 0.075).setLore(["Click to search"])
        this.pageTitle = new SoopyTextElement().setText("§5Your Museum").setMaxTextScale(10).setLocation(0, 0, 1, 1)
        box.addChild(this.pageTitle)
        this.mainPage.addChild(box)

        this.searchText = ""
        let search = new TextBox().setLocation(0.5 - widthPer * 0.75, 0.25, widthPer * 2 * 0.75, 0.075)
        box.addEvent(new SoopyMouseClickEvent().setHandler(() => {
            box.visable = false
            search.visable = true
            search.select()
        }))
        search.visable = false
        search.text.mouseClickG = (mouseX, mouseY) => {
            if (search.text.selected && !this.searchText) {
                box.visable = true
                search.visable = false
            }
            search.text.selected = false
        }
        search.text.addEvent(new SoopyContentChangeEvent().setHandler((newVal, oldVal, resetFunction) => {
            this.searchText = newVal
            this.showSearchItems()
        }))
        this.mainPage.addChild(search)
        this.mainPage.addEvent(new SoopyOpenGuiEvent().setHandler(() => {
            box.visable = true
            search.visable = false
            search.text.selected = false
            search.setText("")
            this.searchText = ""
        }))

        this.nextButton = new ButtonWithArrow().setLocation(0.5 + widthPer * 3 / 2 - widthPer / 2, 0.25, widthPer / 2, 0.075).setText("§0Next Page")
        this.nextButton.addEvent(new SoopyMouseClickEvent().setHandler(() => {
            if (this.nextButton.visable) this.nextPage()
        }))
        this.mainPage.addChild(this.nextButton)

        this.previousButton = new ButtonWithArrow().setLocation(0.5 - widthPer * 3 / 2, 0.25, widthPer / 2, 0.075).setText("§0Previous Page").setDirectionRight(false)
        this.previousButton.addEvent(new SoopyMouseClickEvent().setHandler(() => {
            if (this.previousButton.visable) this.previousPage()
        }))
        this.mainPage.addChild(this.previousButton)

        this.nextButton.visable = false
        this.previousButton.visable = false

        this.donateTitleBox = new SoopyBoxElement().setLocation(0.5 + widthPer * 3 / 2 + 0.025, 0.25, 0.5 - widthPer * 1.5 - 0.05, 0.075)
        let donateTitle = new SoopyTextElement().setText("§5Donate").setMaxTextScale(10).setLocation(0, 0, 1, 1)

        this.donateTitleBox.addChild(donateTitle)
        this.mainPage.addChild(this.donateTitleBox)

        this.donateBox = new SoopyBoxElement().setLocation(0.5 + widthPer * 3 / 2 + 0.025, 0.35, 0.5 - widthPer * 1.5 - 0.05, 0.6).setScrollable(true).enableFrameBuffer()
        this.mainPage.addChild(this.donateBox)

        this.favoriteTitleBox = new SoopyBoxElement().setLocation(0.025, 0.25, 0.5 - widthPer * 1.5 - 0.05, 0.075)
        let favoriteTitle = new SoopyTextElement().setText("§5Favourite Items").setMaxTextScale(10).setLocation(0, 0, 1, 1)

        this.favoriteTitleBox.addChild(favoriteTitle)
        this.mainPage.addChild(this.favoriteTitleBox)

        this.favoriteBox = new SoopyBoxElement().setLocation(0.025, 0.35, 0.5 - widthPer * 1.5 - 0.05, 0.6).setScrollable(true).enableFrameBuffer()
        this.mainPage.addChild(this.favoriteBox)

        this.itemsBox = new SoopyBoxElement().setLocation(0.5 - widthPer * 3 / 2, 0.35, widthPer * 3, 0.6).enableFrameBuffer()
        this.mainPage.addChild(this.itemsBox)

        new Array(this.donateBox, this.favoriteBox, this.itemsBox).forEach((box, i) => {
            box.addEvent(new SoopyHoverChangeEvent().setHandler((hovered) => {
                if (i === 2) {
                    if (this.searchText) {

                    } else {
                        box.enableFrameBuffer()
                        return
                    }
                }
                if (hovered) {
                    box.disableFrameBuffer()
                } else {
                    box.enableFrameBuffer()
                    box.dirtyFrameBuffer(1000)
                }
            }))
        })

        this.donateItems = []

        this.confirm_temp = ""

        this.replacePage = {
            "Your Museum": "Museum",
            " Weapons": "Weapons",
            " Armor Sets": "Armor Sets",
            " Rarities": "Rarities",
            " Special Items": "Special Items"
        }

        this.tickI = 0

        this.lastGuiTitle = ""

        this.favoriteItems = JSON.parse(FileLib.read("soopyAddonsData", "museumFavoriteData.json") || "[]") || []
        this.favoriteIds = this.favoriteItems.map(a => a.sb_id)
        this.updatedFavorites(false)
    }

    saveMuseumCache() {
        //Called on worldUnload, and ever 30 seconds
        if (this.itemsInPagesSaved) return
        this.itemsInPagesSaved = true

        new Thread(() => {
            FileLib.write("soopyAddonsData", "museumItemsCache.json", JSON.stringify(this.itemsInPages))
        }).start()
    }

    clickedTopButton(type) {
        if (ChatLib.removeFormatting(Player.getContainer().getStackInSlot(4).getName()) === type) return

        if (Player.getContainer().getName() === "Your Museum") {
            //if on main page can just directly click on it
            switch (type) {
                case "Weapons":
                    Player.getContainer().click(19, false, "MIDDLE")
                    break
                case "Armor Sets":
                    Player.getContainer().click(21, false, "MIDDLE")
                    break
                case "Rarities":
                    Player.getContainer().click(23, false, "MIDDLE")
                    break
                case "Special Items":
                    Player.getContainer().click(25, false, "MIDDLE")
                    break
            }
        } else {
            Player.getContainer().click(48, false, "MIDDLE")
        }
    }

    nextPage() {
        let itempages = ["Weapons", "Armor Sets", "Rarities", "Special Items"]
        if (itempages.includes(this.replacePage[Player.getContainer().getName().split("➜").pop()])) {
            Player.getContainer().click(53, false, "MIDDLE")

            let [currPage, pageNum] = Player.getContainer().getName().split(")")[0].split("(")[1].split("/").map(a => parseInt(a))
            this.regenItems(currPage + 1)
        }
    }

    previousPage() {
        let itempages = ["Weapons", "Armor Sets", "Rarities", "Special Items"]
        if (itempages.includes(this.replacePage[Player.getContainer().getName().split("➜").pop()])) {
            Player.getContainer().click(45, false, "MIDDLE")

            let [currPage, pageNum] = Player.getContainer().getName().split(")")[0].split("(")[1].split("/").map(a => parseInt(a))
            this.regenItems(currPage - 1)
        }
    }

    tickMenu(first = false) {
        if (!first && (this.tickI++) % 5 !== 0) {
            if (this.lastGuiTitle === Player.getContainer().getName()) {
                return
            }
        }
        this.lastGuiTitle = Player.getContainer().getName()

        if (Player.getContainer().getName() === "Your Museum") {//main page
            if (!Player.getContainer().getStackInSlot(19)) return

            let lore = Player.getContainer().getStackInSlot(19).getLore()
            lore.forEach((line, i) => {
                if (i === 0) return

                if (line.split(" ")?.[1]?.includes("/")) {
                    let data = ChatLib.removeFormatting(line).split(" ")[1].split("/")

                    this.weaponsProgressBar.setProgress(parseInt(data[0]) / parseInt(data[1]))
                    this.weaponsPercentageText.setText("§0Items Donated: §7" + data[0] + "/" + data[1])
                }
            })
            this.weaponsIndicator.setLore(lore)

            lore = Player.getContainer().getStackInSlot(21).getLore()
            lore.forEach((line, i) => {
                if (i === 0) return

                if (line.split(" ")?.[1]?.includes("/")) {
                    let data = ChatLib.removeFormatting(line).split(" ")[1].split("/")

                    this.armourProgressBar.setProgress(parseInt(data[0]) / parseInt(data[1]))
                    this.armourPercentageText.setText("§0Items Donated: §7" + data[0] + "/" + data[1])
                }
            })
            this.armourIndicator.setLore(lore)

            lore = Player.getContainer().getStackInSlot(23).getLore()
            lore.forEach((line, i) => {
                if (i === 0) return

                if (line.split(" ")?.[1]?.includes("/")) {
                    let data = ChatLib.removeFormatting(line).split(" ")[1].split("/")

                    this.raritiesProgressBar.setProgress(parseInt(data[0]) / parseInt(data[1]))
                    this.raritiesPercentageText.setText("§0Items Donated: §7" + data[0] + "/" + data[1])
                }
            })
            this.raritiesIndicator.setLore(lore)

            lore = Player.getContainer().getStackInSlot(25).getLore()
            lore.forEach((line, i) => {
                if (i === 0) return

                if (ChatLib.removeFormatting(line).startsWith("Items Donated: ")) {
                    this.specialPercentageText.setText("§0Items Donated: §7" + ChatLib.removeFormatting(line).split(": ")[1])
                }
            })
            this.specialIndicator.setLore(lore)

            if ((this.pageTitle.text !== ("§5" + Player.getContainer().getName()) || first) && !this.searchText) {
                this.itemsBox.clearChildren()
                let rewardsButton = new ButtonWithArrow().setText("§5Rewards").setLocation(0.1, 0.05, 0.8, 0.2)
                rewardsButton.addEvent(new SoopyMouseClickEvent().setHandler(() => {
                    Player.getContainer().click(40, false, "MIDDLE")
                }))
                this.itemsBox.addChild(rewardsButton)
                let browserButton = new ButtonWithArrow().setText("§5Museum Browser").setLocation(0.1, 0.3, 0.8, 0.2)
                browserButton.addEvent(new SoopyMouseClickEvent().setHandler(() => {
                    Player.getContainer().click(50, false, "MIDDLE")
                }))
                this.itemsBox.addChild(browserButton)

                this.itemsBox.dirtyFrameBuffer()
            }
        }

        this.nextButton.visable = false
        this.previousButton.visable = false

        this.donateTitleBox.visable = false
        this.donateBox.visable = false

        let itempages = ["Weapons", "Armor Sets", "Rarities", "Special Items"]
        if (itempages.includes(this.replacePage[Player.getContainer().getName().split("➜").pop()])) {
            let page = this.replacePage[Player.getContainer().getName().split("➜").pop()]
            let currPage = 0
            let pageNum = Player.getContainer().getStackInSlot(4) ? Math.ceil(ChatLib.removeFormatting(Player.getContainer().getStackInSlot(4).getLore().pop().split("/").pop()) / 28) : 0

            // {
            //     let item = Player.getContainer().getStackInSlot(45)
            //     if (item) {
            //         let lore = item.getLore()
            //         let lastLine = ChatLib.removeFormatting(lore[lore.length - 1]).trim()
            //         let num = lastLine.match(/(\d+)$/g)
            //         currPage = parseInt(num) + 1
            //     }
            // }
            // {
            //     let item = Player.getContainer().getStackInSlot(53)
            //     if (item) {
            //         let lore = item.getLore()
            //         let lastLine = ChatLib.removeFormatting(lore[lore.length - 1]).trim()
            //         let num = lastLine.match(/(\d+)$/g)
            //         currPage = parseInt(num) - 1
            //     }
            // }
            console.log(currPage, pageNum)

            if (!this.searchText) {
                if (currPage > 1) {
                    this.previousButton.visable = true
                    if (Player.getContainer().getStackInSlot(45)) this.previousButton.setLore(Player.getContainer().getStackInSlot(45).getLore())
                }
                if (currPage < pageNum) {
                    this.nextButton.visable = true
                    if (Player.getContainer().getStackInSlot(53)) this.nextButton.setLore(Player.getContainer().getStackInSlot(53).getLore())
                }
            }

            this.donateTitleBox.visable = true
            this.donateBox.visable = true
            let oldDonateItems = JSON.stringify(this.donateItems)
            this.donateItems = []
            let donateArmorSets = {}
            let slot = 0
            for (let item of Player.getContainer().getItems()) {
                if (!item) continue
                if (item.getID() === -1) continue
                let lore = item.itemStack[m.getTooltip](Player.getPlayer(), false)
                for (let line of lore) {
                    if (ChatLib.removeFormatting(line) === "Click to donate item!") {
                        let sb_id = utils.getSBID(item)

                        this.donateItems.push({
                            sb_id: sb_id || "NA",
                            name: item.getName() || "",
                            lore: item.getLore() || [],
                            slot: slot
                        })
                    }
                    if (ChatLib.removeFormatting(line) === "Click to donate armor set!") {
                        let sb_id = utils.getSBID(item)

                        let setId = sb_id.split("_")
                        setId.pop()
                        setId = setId.join("_")

                        donateArmorSets[setId] = (donateArmorSets[setId] || 0) + 1

                        if (donateArmorSets[setId] === 3) {
                            this.donateItems.push({
                                sb_id: sb_id || "NA",
                                name: item.getName() || "",
                                lore: item.getLore() || [],
                                slot: slot
                            })
                        }

                    }
                }
                slot++
            }
            if (oldDonateItems !== JSON.stringify(this.donateItems)) {
                this.regenDonateItems()
            }

            if (!this.itemsInPages[page]) this.itemsInPages[page] = []

            //10-16 43
            let changed = false
            for (let i = 0; i < 4; i++) {
                for (let j = 10; j < 17; j++) {
                    let slot = i * 9 + j
                    let item = Player.getContainer().getStackInSlot(slot)
                    let sb_id = utils.getSBID(item)
                    if (!this.itemsInPages[page][currPage]) this.itemsInPages[page][currPage] = []

                    if (item && item.getID() !== -1) {

                        let itemData = {
                            sb_id: "NA",
                            name: item.getName() || "",
                            lore: item.getLore() || []
                        }

                        if (sb_id) {
                            itemData.sb_id = sb_id
                        }
                        if (!this.itemsInPages[page][currPage][slot] || this.itemsInPages[page][currPage][slot].sb_id !== itemData.sb_id) {
                            this.itemsInPages[page][currPage][slot] = itemData

                            changed = true
                            this.itemsInPagesSaved = false
                        }
                    } else {
                        if (this.itemsInPages[page][currPage][slot]) {
                            delete this.itemsInPages[page][currPage][slot]

                            changed = true
                            this.itemsInPagesSaved = false
                        }
                    }
                }
            }
            if (changed || this.guiUpdated || first) this.regenItems(currPage)
        }

        if (Player.getContainer().getName() === "Confirm Donation") {
            let this_confirm_temp_str = (Player.getContainer().getStackInSlot(4)?.getName() || "") + (Player.getContainer().getStackInSlot(2)?.getName() || "") + (Player.getContainer().getStackInSlot(20)?.getName() || "") + (Player.getContainer().getStackInSlot(24)?.getName() || "")//4, 24, 20
            if (this.confirm_temp !== this_confirm_temp_str || first) {
                this.confirm_temp = this_confirm_temp_str

                this.itemsBox.clearChildren()

                let isArmour = utils.getSBID(Player.getContainer().getStackInSlot(4)) === null
                if (isArmour) {
                    let name = Player.getContainer().getStackInSlot(2).getName()
                    let itemBox = new BoxWithText().setText(name.startsWith("§f") ? "&7" + name.substr(2) : name).setLocation(0.1, 0.05, 0.8, 0.2).setLore(Player.getContainer().getStackInSlot(2).getLore())

                    this.itemsBox.addChild(itemBox)
                } else {
                    let name = Player.getContainer().getStackInSlot(4).getName()
                    let itemBox = new BoxWithText().setText(name.startsWith("§f") ? "&7" + name.substr(2) : name).setLocation(0.1, 0.05, 0.8, 0.2).setLore(Player.getContainer().getStackInSlot(4).getLore())

                    this.itemsBox.addChild(itemBox)
                }

                if (Player.getContainer().getStackInSlot(24) && Player.getContainer().getStackInSlot(20)) {

                    let cancelButton = new ButtonWithArrow().setText("§cCancel").setLocation(0.1, 0.4, 0.35, 0.2).setDirectionRight(false).setLore(Player.getContainer().getStackInSlot(24).getLore())
                    cancelButton.addEvent(new SoopyMouseClickEvent().setHandler(() => {
                        Player.getContainer().click(24, false, "LEFT")
                    }))
                    this.itemsBox.addChild(cancelButton)

                    let confirmButton = new ButtonWithArrow().setText("§aConfirm Donation").setLocation(0.55, 0.4, 0.35, 0.2).setLore(Player.getContainer().getStackInSlot(20).getLore())
                    confirmButton.addEvent(new SoopyMouseClickEvent().setHandler(() => {
                        Player.getContainer().click(20, false, "LEFT")
                    }))
                    this.itemsBox.addChild(confirmButton)
                }

                this.itemsBox.dirtyFrameBuffer()
            }

            this.favoriteBox.visable = false
            this.favoriteTitleBox.visable = false
        } else {
            if (this.confirm_temp && this.searchText) {
                this.showSearchItems()
            }
            this.confirm_temp = ""

            this.favoriteBox.visable = true
            this.favoriteTitleBox.visable = true
        }

        this.pageTitle.setText("§5" + Player.getContainer().getName())
        this.guiUpdated = false
    }

    regenDonateItems() {
        this.donateBox.clearChildren()
        this.donateItems.forEach((item, i) => {
            let itemButton = new ButtonWithArrow().setText(item.name.startsWith("§f") ? "&7" + item.name.substr(2) : item.name).setLocation(0.05, 0.025 + 0.125 * i, 0.9, 0.1).setLore(item.lore)
            itemButton.addEvent(new SoopyMouseClickEvent().setHandler(() => {
                Player.getContainer().click(item.slot, false, "LEFT")
            }))
            this.donateBox.addChild(itemButton)
        })

        this.donateBox.dirtyFrameBuffer()
    }

    showSearchItems() {
        if (Player.getContainer().getName() === "Confirm Donation") return

        if (!this.searchText) {
            this.tickMenu(true)
            return
        }


        this.itemsBox.clearChildren()

        let items = []

        // this.itemsInPages[page][page2]
        Object.keys(this.itemsInPages).forEach((pageKey) => {
            let page = this.itemsInPages[pageKey]
            page.forEach((page2, page2I) => {
                if (!page2) return
                if (items.length >= 4 * 7) return
                page2.forEach((item, slotNum) => {
                    if (!item) return
                    if (items.length >= 4 * 7) return
                    if (item.name.toLowerCase().includes(this.searchText.toLowerCase())) {
                        let loreNew = []
                        Object.values(item.lore).forEach(a => {
                            loreNew.push(a)
                        })
                        item.lore = loreNew
                        item.page = pageKey //category eg: Weapons, armour sets ect
                        item.page2 = page2I //pagenum of category
                        item.slotNum = slotNum //slotnum

                        items.push(item)
                    }
                })
            })
        })

        let y = 0.0325
        let itemNum = 0
        let width = 3
        let widthPer = 1 / (width + 1)
        let offset = 0.0125

        items.forEach((slot, slotNum) => {
            if (!slot) return

            let child

            if (slot.sb_id === "NA") {
                child = new BoxWithText().setText(slot.name.startsWith("§f") ? "&7" + slot.name.substr(2) : slot.name).setLore(slot.lore)
                if (slot.name.startsWith("§c")) {
                    child.setColor(255, 100, 100)
                    child.setText("&0" + slot.name.substr(2))
                }
                if (slot.name.startsWith("§e")) {
                    child.setColor(255, 255, 100)
                    child.setText("&0" + slot.name.substr(2))
                }
            } else {
                let fItem = slot
                child = new ButtonWithArrow().setText(slot.name.startsWith("§f") ? "&7" + slot.name.substr(2) : slot.name).setLore(slot.lore)
                child.addEvent(new SoopyMouseClickEvent().setHandler((mouseX, mouseY, button) => {
                    if (button === 2) { //middle click -> add item to favorites
                        this.addItemToFavorites(fItem, fItem.page, fItem.page2, fItem.slotNum)
                        return
                    }
                    // Player.getContainer().click(item.slotNum, false,button===1?"RIGHT":"LEFT")

                    let currPage, pageNum
                    if (Player.getContainer().getName().includes("/")) {
                        [currPage, pageNum] = Player.getContainer().getName().split(")")[0].split("(")[1].split("/").map(a => parseInt(a))
                    }

                    if (this.replacePage[Player.getContainer().getName().split("➜").pop()] === fItem.page) {
                        if (currPage === fItem.page2) {
                            Player.getContainer().click(fItem.slotNum, false, "LEFT")
                        } else {
                            if (currPage < fItem.page2) {
                                Player.getContainer().click(53, false, "MIDDLE")
                            } else {
                                Player.getContainer().click(45, false, "MIDDLE")
                            }
                        }
                    } else {
                        this.clickedTopButton(fItem.page)
                    }
                })).addEvent(new SoopyRenderEvent().setHandler(() => {
                    if (child.hovered) {

                        child.setColorOffset(-20, -20, -20, 100)

                        Renderer.translate(0, 0, 100)
                        Renderer.drawRect(Renderer.color(0, 0, 0, 100), child.location.getXExact(), child.location.getYExact(), child.location.getWidthExact(), child.location.getHeightExact())

                        let clicks = "?"
                        let currPage, pageNum
                        if (Player.getContainer().getName().includes("/")) {
                            [currPage, pageNum] = Player.getContainer().getName().split(")")[0].split("(")[1].split("/").map(a => parseInt(a))
                        }
                        let pageClicks = Math.abs(currPage - fItem.page2)
                        if (this.replacePage[Player.getContainer().getName().split("➜").pop()] === fItem.page) {
                            clicks = (pageClicks + 1) + ""
                        } else {
                            if (Player.getContainer().getName() === "Your Museum") {
                                clicks = (1 + fItem.page2) + ""
                            } else {
                                clicks = (2 + fItem.page2) + ""
                            }
                        }

                        Renderer.translate(0, 0, 100)
                        renderLibs.drawStringCenteredFull(clicks, child.location.getXExact() + child.location.getWidthExact() / 2, child.location.getYExact() + child.location.getHeightExact() / 2, Math.min(child.location.getWidthExact() / Renderer.getStringWidth(clicks) / 4, child.location.getHeightExact() / 4 / 2))

                    }
                }))
                if (this.favoriteIds.includes(slot.sb_id)) {
                    child.setColor(200, 255, 200)
                }
            }
            child.setLocation(offset + widthPer * itemNum, y, widthPer * 9 / 10, 0.125)
            this.itemsBox.addChild(child)

            itemNum++
            if (itemNum > width) {
                itemNum = 0
                y += 0.135
            }
        })

        this.itemsBox.dirtyFrameBuffer()
    }

    regenItems(page2) {
        if (this.searchText) return

        this.itemsBox.clearChildren()

        let page = this.replacePage[Player.getContainer().getName().split("➜").pop()]

        let y = 0.0325
        let itemNum = 0
        let width = 3
        let widthPer = 1 / (width + 1)
        let offset = 0.0125

        if (!this.itemsInPages[page][page2]) this.itemsInPages[page][page2] = []

        this.itemsInPages[page][page2].forEach((slot, slotNum) => {
            if (!slot) return

            let child

            if (slot.sb_id === "NA") {
                child = new BoxWithText().setText(slot.name.startsWith("§f") ? "&7" + slot.name.substr(2) : slot.name).setLore(slot.lore)
                if (slot.name.startsWith("§c")) {
                    child.setColor(255, 100, 100)
                    child.setText("&0" + slot.name.substr(2))
                }
                if (slot.name.startsWith("§e")) {
                    child.setColor(255, 255, 100)
                    child.setText("&0" + slot.name.substr(2))
                }
            } else {
                child = new ButtonWithArrow().setText(slot.name.startsWith("§f") ? "&7" + slot.name.substr(2) : slot.name).setLore(slot.lore)
                child.addEvent(new SoopyMouseClickEvent().setHandler((mouseX, mouseY, button) => {
                    if (button === 2) { //middle click -> add item to favorites
                        this.addItemToFavorites(slot, page, page2, slotNum)
                        return
                    }
                    // Player.getContainer().click(slotNum, false,button===1?"RIGHT":"LEFT")
                    Player.getContainer().click(slotNum, false, "LEFT") //TODO: add right click support for viewing armour sets
                }))
                if (this.favoriteIds.includes(slot.sb_id)) {
                    child.setColor(200, 255, 200)
                }
            }
            child.setLocation(offset + widthPer * itemNum, y, widthPer * 9 / 10, 0.125)
            this.itemsBox.addChild(child)

            itemNum++
            if (itemNum > width) {
                itemNum = 0
                y += 0.135
            }
        })

        this.itemsBox.dirtyFrameBuffer()
    }

    addItemToFavorites(slot, page, page2, slotNum) {
        if (page === "Special Items") {
            new Notification("§cError!", ["You cant add Special Items", ["to favorites"]])
            return
        }
        if (this.favoriteItems.map(a => a.sb_id).includes(slot.sb_id)) {
            //remove from favorites
            this.favoriteItems = this.favoriteItems.filter(a => a.sb_id !== slot.sb_id)
            this.favoriteIds = this.favoriteIds.filter(a => a !== slot.sb_id)
            this.regenItems(page2)
            this.updatedFavorites()
            return
        }
        let loreNew = []
        slot.lore.forEach(a => {
            loreNew.push(a)
        })
        slot.lore = loreNew
        slot.page = page //category eg: Weapons, armour sets ect
        slot.page2 = page2 //pagenum of category
        slot.slotNum = slotNum //slotnum
        this.favoriteItems.push(slot)
        this.favoriteIds.push(slot.sb_id)
        this.regenItems(page2)
        this.updatedFavorites()
    }

    updatedFavorites(saveToFile = true) {
        this.favoriteBox.clearChildren()

        if (this.favoriteItems.length === 0) {
            let item = new SoopyMarkdownElement().setText("Middle click to add an item to your favorites list").setLocation(0.05, 0.025, 0.9, 0.9)

            this.favoriteBox.addChild(item)
        }

        this.favoriteItems.forEach((fItem, i) => {
            let item = new ButtonWithArrow().setText(fItem.name.startsWith("§f") ? "&7" + fItem.name.substr(2) : fItem.name).setLocation(0.05, 0.025 + 0.125 * i, 0.9, 0.1).setLore(fItem.lore)

            item.addEvent(new SoopyMouseClickEvent().setHandler((mouseX, mouseY, button) => {
                if (button === 2) { //middle click -> remove item from favorites (calling add will remove because it alr exists)
                    this.addItemToFavorites(fItem, fItem.page, fItem.page2, fItem.slotNum)
                    return
                }
                // Player.getContainer().click(item.slotNum, false,button===1?"RIGHT":"LEFT")

                let currPage, pageNum
                if (Player.getContainer().getName().includes("/")) {
                    [currPage, pageNum] = Player.getContainer().getName().split(")")[0].split("(")[1].split("/").map(a => parseInt(a))
                }

                if (this.replacePage[Player.getContainer().getName().split("➜").pop()] === fItem.page) {
                    if (currPage === fItem.page2) {
                        Player.getContainer().click(fItem.slotNum, false, "LEFT")
                    } else {
                        if (currPage < fItem.page2) {
                            Player.getContainer().click(53, false, "MIDDLE")
                        } else {
                            Player.getContainer().click(45, false, "MIDDLE")
                        }
                    }
                } else {
                    this.clickedTopButton(fItem.page)
                }
            })).addEvent(new SoopyRenderEvent().setHandler(() => {
                if (item.hovered) {

                    item.setColorOffset(-20, -20, -20, 100)

                    Renderer.translate(0, 0, 100)
                    Renderer.drawRect(Renderer.color(0, 0, 0, 100), item.location.getXExact(), item.location.getYExact(), item.location.getWidthExact(), item.location.getHeightExact())

                    let clicks = "?"
                    let currPage, pageNum
                    if (Player.getContainer().getName().includes("/")) {
                        [currPage, pageNum] = Player.getContainer().getName().split(")")[0].split("(")[1].split("/").map(a => parseInt(a))
                    }
                    let pageClicks = Math.abs(currPage - fItem.page2)
                    if (this.replacePage[Player.getContainer().getName().split("➜").pop()] === fItem.page) {
                        clicks = (pageClicks + 1) + ""
                    } else {
                        if (Player.getContainer().getName() === "Your Museum") {
                            clicks = (1 + fItem.page2) + ""
                        } else {
                            clicks = (2 + fItem.page2) + ""
                        }
                    }

                    Renderer.translate(0, 0, 100)
                    renderLibs.drawStringCenteredFull(clicks, item.location.getXExact() + item.location.getWidthExact() / 2, item.location.getYExact() + item.location.getHeightExact() / 2, Math.min(item.location.getWidthExact() / Renderer.getStringWidth(clicks) / 4, item.location.getHeightExact() / 4 / 2))

                }
            }))

            this.favoriteBox.addChild(item)
        })

        if (saveToFile) {
            new Thread(() => {
                FileLib.write("soopyAddonsData", "museumFavoriteData.json", JSON.stringify(this.favoriteItems))
            }).start()
        }

        this.favoriteBox.dirtyFrameBuffer()
    }

    guiOpened(event) {
        let name = ""
        if (event.gui && event.gui.field_147002_h instanceof ContainerChest) {
            name = event.gui.field_147002_h.func_85151_d().func_145748_c_().func_150260_c()
        }
        if (this.dontOpen > 0) {
            this.dontOpen--
        }
        if (this.soopyGui.ctGui.isOpen()) {
            if (event.gui && event.gui.field_147002_h) {
                Player.getPlayer().field_71070_bA = event.gui.field_147002_h

                if (Player.getContainer().getName() === "Museum Rewards") {
                    return
                }
                if (Player.getContainer().getName().startsWith("Museum Browser")) {
                    return
                }

                event.gui = this.soopyGui.ctGui
                this.guiUpdated = true
                this.soopyGui.ctGui.open()

                this.itemsBox.dirtyFrameBuffer()
            }
            return
        }
        if (this.isInMuseum) {
            this.soopyGui.ctGui.open()

            this.itemsBox.dirtyFrameBuffer()
        } else {
            if (name === "Your Museum" && !this.isInMuseum) {

                if (event.gui && event.gui.field_147002_h) Player.getPlayer().field_71070_bA = event.gui.field_147002_h

                this.isInMuseum = true

                this.soopyGui.open()
                event.gui = this.soopyGui.ctGui
                this.guiOpenTickThing = true

                this.itemsBox.clearChildren()
                let rewardsButton = new ButtonWithArrow().setText("§5Rewards").setLocation(0.1, 0.05, 0.8, 0.2)
                rewardsButton.addEvent(new SoopyMouseClickEvent().setHandler(() => {
                    Player.getContainer().click(40, false, "MIDDLE")
                }))
                this.itemsBox.addChild(rewardsButton)
                let browserButton = new ButtonWithArrow().setText("§5Museum Browser").setLocation(0.1, 0.3, 0.8, 0.2)
                browserButton.addEvent(new SoopyMouseClickEvent().setHandler(() => {
                    Player.getContainer().click(50, false, "MIDDLE")
                }))
                this.itemsBox.addChild(browserButton)

                this.nextButton.visable = false
                this.previousButton.visable = false

                this.donateTitleBox.visable = false
                this.donateBox.visable = false

                this.pageTitle.setText("§5" + name)

                this.tickMenu(true)

                this.itemsBox.dirtyFrameBuffer()
            }
        }
    }

    keyPress(key, keyId) {
        if (keyId === 1) { //escape key
            this.isInMuseum = false
            // this.dontOpen = 1
            Client.currentGui.close()
        }
    }

    tick() {
        if (this.isInMuseum) {
            if (this.soopyGui.ctGui.isOpen() || this.guiOpenTickThing) {
                this.tickMenu()

                this.guiOpenTickThing = false
            } else {
                // Client.currentGui.close()
                this.isInMuseum = false

                this.lastClosed = Date.now()
            }
        }

        if (!(this.soopyGui.ctGui.isOpen() || this.guiOpenTickThing) && Date.now() - this.lastClosed > 1000) {
            this.weaponsProgressBar.setProgress(0)
            this.armourProgressBar.setProgress(0)
            this.raritiesProgressBar.setProgress(0)
        }

        if (this.dontOpen > 0) {
            Client.currentGui.close()
        }
    }
}

export default MuseumGui;