Skip to content

Commit b996f37

Browse files
committed
This should never happen fixed and better error message
1 parent 5b88649 commit b996f37

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

src/main/kotlin/dev/newspicel/di/commands/CommandsHelper.kt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package dev.newspicel.di.commands
22

3+
import dev.newspicel.di.DIJavaPlugin
34
import kotlinx.coroutines.CoroutineScope
45
import kotlinx.coroutines.Dispatchers
56
import kotlinx.coroutines.launch
67
import kotlinx.coroutines.runBlocking
7-
import net.kyori.adventure.text.format.TextColor
8-
import dev.newspicel.di.DIJavaPlugin
98
import net.kyori.adventure.text.Component.text
9+
import net.kyori.adventure.text.format.TextColor
1010
import org.bukkit.command.CommandExecutor
1111
import org.bukkit.command.CommandSender
1212
import org.bukkit.command.PluginCommand
@@ -51,8 +51,6 @@ object CommandsHelper {
5151
}
5252

5353
private fun createCommandExecutor(plugin: DIJavaPlugin, func: KFunction<*>, command: Command): CommandExecutor = CommandExecutor { sender, _, label, args ->
54-
if (command.label != label) error("This should never happen")
55-
5654
if (!checkPermissions(sender, func)) {
5755
sender.sendMessage(text("You don't have permission to execute this command").color(TextColor.color(0xFF0000)))
5856
return@CommandExecutor false
@@ -88,8 +86,6 @@ object CommandsHelper {
8886
}
8987

9088
private fun createTabCompleter(plugin: DIJavaPlugin, func: KFunction<*>, tabComplete: TabComplete): TabCompleter = TabCompleter { sender, _, label, args ->
91-
if (tabComplete.label != label) error("This should never happen")
92-
9389
if (!checkPermissions(sender, func)) {
9490
return@TabCompleter emptyList()
9591
}

src/main/kotlin/dev/newspicel/di/events/EventHelper.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package dev.newspicel.di.events
22

3+
import dev.newspicel.di.DIJavaPlugin
34
import kotlinx.coroutines.CoroutineScope
45
import kotlinx.coroutines.Dispatchers
56
import kotlinx.coroutines.launch
67
import kotlinx.coroutines.runBlocking
7-
import dev.newspicel.di.DIJavaPlugin
88
import org.bukkit.event.EventException
99
import org.bukkit.event.Listener
1010
import org.bukkit.plugin.EventExecutor
@@ -31,7 +31,7 @@ object EventHelper {
3131
}
3232

3333
private fun createEventExecutor(plugin: DIJavaPlugin, func: KFunction<*>, eventAnnotation: Event): EventExecutor = EventExecutor { _, event ->
34-
if (!eventAnnotation.event.isInstance(event)) error("Event is not instance of ${eventAnnotation.event}, this should never happen!")
34+
if (!eventAnnotation.event.isInstance(event)) error("Event is not instance of ${eventAnnotation.event} it is instance of ${event::class}, this should never happen!")
3535

3636
val params = plugin.getParameterMap(func.parameters, event)
3737

0 commit comments

Comments
 (0)