Skip to content

Commit

Permalink
Merge pull request #32 from TheProgramSrc/fix/software-type
Browse files Browse the repository at this point in the history
  • Loading branch information
Im-Fran committed Apr 9, 2022
2 parents 29391fd + 268aee6 commit 76870ef
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,6 @@
## v0.3.4 - Snapshot
* Fixed SoftwareType Checker

## v0.3.3 - Snapshot
* Configured Renovate
* Updated dependencies
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Expand Up @@ -7,7 +7,7 @@ plugins {
id 'org.jetbrains.dokka' version '1.6.10'
}

def projectVersion = (System.getenv("VERSION") ?: '0.3.3-SNAPSHOT').replaceFirst("v", "").replace('/', '')
def projectVersion = (System.getenv("VERSION") ?: '0.3.4-SNAPSHOT').replaceFirst("v", "").replace('/', '')

group 'xyz.theprogramsrc'
version projectVersion
Expand Down
@@ -1,5 +1,7 @@
package xyz.theprogramsrc.simplecoreapi.global.utils

import java.util.Objects

/**
* Representation of a ServerSoftware
* @param check The function to check if the software is running the server or not.
Expand Down Expand Up @@ -49,19 +51,25 @@ enum class SoftwareType(val check: () -> Boolean = { false }, val display: Strin
// Proxies
BUNGEE(check = {
try {
val proxyServerInstance = Class.forName("net.md_5.bungee.api.ProxyServer").getMethod("getInstance").invoke(null) as Class<*>
val name = proxyServerInstance.getMethod("getName").invoke(proxyServerInstance) as String
name.equals("BungeeCord")
val proxyServer = Class.forName("net.md_5.bungee.api.ProxyServer")
val proxyServerInstanceValue = proxyServer.getDeclaredField("instance").apply {
isAccessible = true
}.get(null)
val proxyServerName = proxyServer.getMethod("getName").invoke(proxyServerInstanceValue) as String
Objects.equals(proxyServerName, "BungeeCord")
} catch (e: Exception) {
false
}
}, "BungeeCord"),

WATERFALL(check = {
try {
val proxyServerInstance = Class.forName("net.md_5.bungee.api.ProxyServer").getMethod("getInstance").invoke(null) as Class<*>
val name = proxyServerInstance.getMethod("getName").invoke(proxyServerInstance) as String
name.equals("Waterfall")
val proxyServer = Class.forName("net.md_5.bungee.api.ProxyServer")
val proxyServerInstanceValue = proxyServer.getDeclaredField("instance").apply {
isAccessible = true
}.get(null)
val proxyServerName = proxyServer.getMethod("getName").invoke(proxyServerInstanceValue) as String
Objects.equals(proxyServerName, "Waterfall")
} catch (e: Exception) {
false
}
Expand Down

0 comments on commit 76870ef

Please sign in to comment.