@@ -26,6 +26,8 @@ object ScriptExecutor {
2626
2727 private val playerCooldowns = mutableMapOf<UUID , MutableMap <Location , Long >>()
2828 private val globalCooldowns = mutableMapOf<Location , Long >()
29+ private val playerAmounts = mutableMapOf<UUID , MutableMap <Location , Int >>()
30+ private val globalAmounts = mutableMapOf<Location , Int >()
2931
3032 fun run (player : Player , scriptData : ScriptData , location : Location , actionType : String = "") {
3133 if (ScriptBlockNext .instance.config.getBoolean(" output_script_log" , false )) {
@@ -132,6 +134,28 @@ object ScriptExecutor {
132134 val channelId = cleanCmd.substringAfter(" :" )
133135 val isInChannel = DiscordSRVManager .getVoiceChannelId(player.uniqueId) == channelId
134136 if (if (isInverted) isInChannel else ! isInChannel) return
137+ } else if (cleanCmd.startsWith(" @perm:" , ignoreCase = true )) {
138+ val perm = cleanCmd.substringAfter(" :" )
139+ val hasPerm = player.hasPermission(perm)
140+ if (if (isInverted) hasPerm else ! hasPerm) return
141+ } else if (cleanCmd.startsWith(" @group:" , ignoreCase = true )) {
142+ val group = cleanCmd.substringAfter(" :" )
143+ val hasGroup = LuckPermsManager .hasGroup(player, group)
144+ if (if (isInverted) hasGroup else ! hasGroup) return
145+ } else if (cleanCmd.startsWith(" @amount:" , ignoreCase = true )) {
146+ val amountLimit = cleanCmd.substringAfter(" :" ).toIntOrNull() ? : 0
147+ val used = playerAmounts[player.uniqueId]?.get(location) ? : 0
148+ if (used >= amountLimit) {
149+ player.sendMsg(" error_amount_limit" , " limit" to amountLimit.toString())
150+ return
151+ }
152+ } else if (cleanCmd.startsWith(" @globalAmount:" , ignoreCase = true )) {
153+ val amountLimit = cleanCmd.substringAfter(" :" ).toIntOrNull() ? : 0
154+ val used = globalAmounts[location] ? : 0
155+ if (used >= amountLimit) {
156+ player.sendMsg(" error_global_amount_limit" , " limit" to amountLimit.toString())
157+ return
158+ }
135159 } else if (cleanCmd.startsWith(" @if " )) {
136160 val ifArgs = cleanCmd.substringAfter(" @if " ).split(" " , limit = 4 )
137161 if (ifArgs.size >= 3 ) {
@@ -185,6 +209,18 @@ object ScriptExecutor {
185209 MythicMobsManager .takeMythicItem(player, mythicId, amount)
186210 }
187211
212+ // Increment amounts
213+ for (line in scriptData.commands) {
214+ val cmd = PlaceholderManager .replace(player, line)
215+ val cleanCmd = cmd.removePrefix(" !" )
216+ if (cleanCmd.startsWith(" @amount:" , ignoreCase = true )) {
217+ val map = playerAmounts.getOrPut(player.uniqueId) { mutableMapOf () }
218+ map[location] = (map[location] ? : 0 ) + 1
219+ } else if (cleanCmd.startsWith(" @globalAmount:" , ignoreCase = true )) {
220+ globalAmounts[location] = (globalAmounts[location] ? : 0 ) + 1
221+ }
222+ }
223+
188224 executeCommands(player, scriptData.commands, 0 )
189225 }
190226
@@ -202,6 +238,11 @@ object ScriptExecutor {
202238 activeCmd.startsWith(" @oldCooldown:" ) || activeCmd.startsWith(" @action:" ) ||
203239 activeCmd.startsWith(" @blockType:" ) ||
204240 activeCmd.startsWith(" @hand:" ) ||
241+ activeCmd.startsWith(" @perm:" , ignoreCase = true ) ||
242+ activeCmd.startsWith(" @group:" , ignoreCase = true ) ||
243+ activeCmd.startsWith(" @amount:" , ignoreCase = true ) ||
244+ activeCmd.startsWith(" @globalAmount:" , ignoreCase = true ) ||
245+ activeCmd.startsWith(" @cancelEvent:" , ignoreCase = true ) ||
205246 activeCmd.startsWith(" @mmid:" , ignoreCase = true ) ||
206247 activeCmd.startsWith(" @dRole:" , ignoreCase = true ) || activeCmd.startsWith(" @dChannel:" , ignoreCase = true )) continue
207248 if (activeCmd.startsWith(" @delay:" )) {
0 commit comments