@@ -8,6 +8,7 @@ import taboolib.common.platform.function.submit
8
8
import taboolib.module.configuration.Configuration
9
9
import taboolib.module.lang.Type
10
10
import taboolib.platform.util.cancelNextChat
11
+ import trplugins.menu.TrMenu
11
12
import trplugins.menu.api.event.MenuOpenEvent
12
13
import trplugins.menu.api.event.MenuPageChangeEvent
13
14
import trplugins.menu.api.receptacle.provider.PlatformProvider
@@ -36,6 +37,7 @@ class Menu(
36
37
companion object {
37
38
38
39
val menus = mutableListOf<Menu >()
40
+ val BEDROCK_DELAY get() = TrMenu .SETTINGS .getLong(" Options.Bedrock-Open-Delay" , 20L )
39
41
40
42
}
41
43
@@ -69,9 +71,11 @@ class Menu(
69
71
70
72
val determinedPage = page ? : settings.determinePage(session)
71
73
74
+ var menuSwitch = false
72
75
if (session.menu == this ) {
73
76
return page(viewer, determinedPage)
74
77
} else if (session.menu != null ) {
78
+ menuSwitch = true
75
79
if (PlatformProvider .isBedrockPlayer(viewer)) {
76
80
session.receptacle?.close(true )
77
81
}
@@ -105,10 +109,21 @@ class Menu(
105
109
loadIcon(session)
106
110
loadTasks(session)
107
111
108
- receptacle.open(viewer)
109
- settings.properties.forEach { (id, value) ->
110
- if (id >= 0 && value != null ) {
111
- receptacle.property(id, value)
112
+ if (menuSwitch && BEDROCK_DELAY > 0 && PlatformProvider .isBedrockPlayer(viewer)) {
113
+ submit(async = Bukkit .isPrimaryThread(), delay = BEDROCK_DELAY ) {
114
+ receptacle.open(viewer)
115
+ settings.properties.forEach { (id, value) ->
116
+ if (id >= 0 && value != null ) {
117
+ receptacle.property(id, value)
118
+ }
119
+ }
120
+ }
121
+ } else {
122
+ receptacle.open(viewer)
123
+ settings.properties.forEach { (id, value) ->
124
+ if (id >= 0 && value != null ) {
125
+ receptacle.property(id, value)
126
+ }
112
127
}
113
128
}
114
129
}
@@ -152,7 +167,13 @@ class Menu(
152
167
} else {
153
168
session.receptacle?.title(title, update = false )
154
169
}
155
- receptacle.open(viewer)
170
+ if (BEDROCK_DELAY > 0 && PlatformProvider .isBedrockPlayer(viewer)) {
171
+ submit(async = Bukkit .isPrimaryThread(), delay = BEDROCK_DELAY ) {
172
+ receptacle.open(viewer)
173
+ }
174
+ } else {
175
+ receptacle.open(viewer)
176
+ }
156
177
}
157
178
}
158
179
0 commit comments