-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from MikChanNoPlugins/dev/dev
v2.1.4
- Loading branch information
Showing
43 changed files
with
365 additions
and
324 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,70 @@ | ||
package dev.mikchan.mcnp.chat | ||
|
||
import dev.mikchan.mcnp.chat.contract.IChatPluginFactory | ||
import dev.mikchan.mcnp.chat.implementation.pre19spigot.Pre19SpigotChatPluginFactory | ||
import dev.mikchan.mcnp.chat.implementation.spigot.SpigotChatPluginFactory | ||
import dev.mikchan.mcnp.chat.implementation.spigot.latest.SpigotLatestChatPluginFactory | ||
import dev.mikchan.mcnp.chat.implementation.spigot.v1_16_5.SpigotV1m16p5ChatPluginFactory | ||
import dev.mikchan.mcnp.chat.implementation.spigot.v1_17.SpigotV1m17ChatPluginFactory | ||
import dev.mikchan.mcnp.chat.implementation.spigot.v1_17_1.SpigotV1m17p1ChatPluginFactory | ||
import dev.mikchan.mcnp.chat.implementation.spigot.v1_18.SpigotV1m18ChatPluginFactory | ||
import dev.mikchan.mcnp.chat.implementation.spigot.v1_18_1.SpigotV1m18p1ChatPluginFactory | ||
import dev.mikchan.mcnp.chat.implementation.spigot.v1_18_2.SpigotV1m18p2ChatPluginFactory | ||
import dev.mikchan.mcnp.chat.implementation.spigot.v1_19.SpigotV1m19ChatPluginFactory | ||
import dev.mikchan.mcnp.chat.implementation.spigot.v1_19_1.SpigotV1m19p1ChatPluginFactory | ||
import dev.mikchan.mcnp.chat.implementation.spigot.v1_19_2.SpigotV1m19p2ChatPluginFactory | ||
import dev.mikchan.mcnp.chat.implementation.spigot.v1_19_3.SpigotV1m19p3ChatPluginFactory | ||
|
||
|
||
internal object FactorySelector { | ||
@Suppress("unused") | ||
private class Version(val major: Int, val minor: Int, val patch: Int) | ||
|
||
private fun getVersion(plugin: ChatPlugin): Version? { | ||
val versionRegex = Regex("""(\d+)\.(\d+)\.(\d+)""") | ||
val versionRegex = Regex("""(\d+)\.(\d+)(?:\.(\d+))?""") | ||
val match = versionRegex.find(plugin.server.bukkitVersion) ?: return null | ||
val (sMajor, sMinor, sPatch) = match.destructured | ||
|
||
val major = sMajor.toIntOrNull() ?: return null | ||
val minor = sMinor.toIntOrNull() ?: return null | ||
val patch = sPatch.toIntOrNull() ?: return null | ||
val patch = sPatch.toIntOrNull() ?: 0 | ||
|
||
return Version(major, minor, patch) | ||
} | ||
|
||
fun selectFactory(plugin: ChatPlugin): IChatPluginFactory { | ||
val version = getVersion(plugin) ?: return SpigotChatPluginFactory(plugin) | ||
val version = getVersion(plugin) ?: return SpigotLatestChatPluginFactory(plugin) | ||
|
||
if (version.major == 1 && version.minor < 19) { | ||
return Pre19SpigotChatPluginFactory(plugin) | ||
} | ||
return when (version.major) { | ||
1 -> when (version.minor) { | ||
16 -> when (version.patch) { | ||
5 -> SpigotV1m16p5ChatPluginFactory(plugin) | ||
else -> SpigotV1m16p5ChatPluginFactory(plugin) | ||
} | ||
|
||
17 -> when (version.patch) { | ||
0 -> SpigotV1m17ChatPluginFactory(plugin) | ||
1 -> SpigotV1m17p1ChatPluginFactory(plugin) | ||
else -> SpigotV1m17p1ChatPluginFactory(plugin) | ||
} | ||
|
||
18 -> when (version.patch) { | ||
0 -> SpigotV1m18ChatPluginFactory(plugin) | ||
1 -> SpigotV1m18p1ChatPluginFactory(plugin) | ||
2 -> SpigotV1m18p2ChatPluginFactory(plugin) | ||
else -> SpigotV1m18p2ChatPluginFactory(plugin) | ||
} | ||
|
||
return SpigotChatPluginFactory(plugin) | ||
19 -> when (version.patch) { | ||
0 -> SpigotV1m19ChatPluginFactory(plugin) | ||
1 -> SpigotV1m19p1ChatPluginFactory(plugin) | ||
2 -> SpigotV1m19p2ChatPluginFactory(plugin) | ||
else -> SpigotV1m19p3ChatPluginFactory(plugin) | ||
} | ||
|
||
else -> SpigotLatestChatPluginFactory(plugin) | ||
} | ||
|
||
// Minecraft 2? | ||
else -> SpigotLatestChatPluginFactory(plugin) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 10 additions & 10 deletions
20
...n/spigot/commands/SpigotCommandManager.kt → ...ation/base/commands/BaseCommandManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ation/spigot/commands/command/ICommand.kt → .../implementation/base/commands/ICommand.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 7 additions & 8 deletions
15
...ation/spigot/events/SpigotEventManager.kt → ...ementation/base/event/BaseEventManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.