Skip to content

Commit db33202

Browse files
remove: useless/not used imports
1 parent 94f9efe commit db33202

File tree

6 files changed

+50
-4
lines changed

6 files changed

+50
-4
lines changed

proxy-bungeecord/src/main/kotlin/app/simplecloud/plugin/proxy/bungeecord/ProxyBungeeCordPlugin.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import app.simplecloud.plugin.proxy.bungeecord.listener.ProxyPingListener
77
import app.simplecloud.plugin.proxy.bungeecord.listener.TabListListener
88
import app.simplecloud.plugin.proxy.shared.config.GeneralConfig
99
import app.simplecloud.plugin.proxy.shared.config.YamlConfig
10-
import app.simplecloud.plugin.proxy.shared.config.motd.MotdLayoutConfiguration
1110
import app.simplecloud.plugin.proxy.shared.config.placeholder.PlaceHolderConfiguration
1211
import app.simplecloud.plugin.proxy.shared.config.tablis.TabListConfiguration
1312
import app.simplecloud.plugin.proxy.shared.handler.MotdLayoutHandler

proxy-bungeecord/src/main/kotlin/app/simplecloud/plugin/proxy/bungeecord/listener/ProxyPingListener.kt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@ package app.simplecloud.plugin.proxy.bungeecord.listener
22

33
import app.simplecloud.plugin.proxy.bungeecord.ProxyBungeeCordPlugin
44
import app.simplecloud.plugin.proxy.shared.config.motd.MaxPlayerDisplayType
5-
import app.simplecloud.plugin.proxy.shared.event.MotdConfiguration
65
import net.kyori.adventure.text.Component
7-
import net.kyori.adventure.text.minimessage.MiniMessage
86
import net.kyori.adventure.text.serializer.bungeecord.BungeeComponentSerializer
7+
import net.md_5.bungee.api.Favicon
98
import net.md_5.bungee.api.ServerPing.*
109
import net.md_5.bungee.api.event.ProxyPingEvent
1110
import net.md_5.bungee.api.plugin.Listener
1211
import net.md_5.bungee.event.EventHandler
12+
import java.awt.image.BufferedImage
13+
import java.io.File
1314
import java.net.InetAddress
1415
import java.net.InetSocketAddress
1516
import java.util.*
17+
import javax.imageio.ImageIO
1618

1719
class ProxyPingListener(
1820
private val plugin: ProxyBungeeCordPlugin
@@ -67,6 +69,15 @@ class ProxyPingListener(
6769
-1
6870
)
6971
}
72+
73+
val favicon = if (motdConfiguration.serverIcon == "") {
74+
response.faviconObject
75+
} else {
76+
val serverIcon: BufferedImage = ImageIO.read(File(motdConfiguration.serverIcon))
77+
Favicon.create(serverIcon)
78+
}
79+
80+
response.setFavicon(favicon)
7081
}
7182

7283
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package app.simplecloud.plugin.proxy.shared.config.motd
22

33
import org.spongepowered.configurate.objectmapping.ConfigSerializable
4+
import java.awt.image.BufferedImage
45

56
@ConfigSerializable
67
data class MotdLayoutConfiguration(
78
val firstLines: List<String> = listOf("<gradient:#00fcff:#0da1a3><bold>SimpleCloud</bold></gradient> <dark_gray>»<gray> Simplify your network <dark_gray>|<bold><#4595ff> 1.12<#545454> - <#4595ff>1.20</bold>"),
89
val secondLines: List<String> = listOf("<dark_gray>× <#178fff>Status<dark_gray>: <bold><#22cc22>Online</bold> <dark_gray>- <#ffffff>%PROXY%"),
910
val playerInfo: List<String> = listOf(),
1011
val versionName: String = "",
12+
var serverIcon: String = "server-icon.png",
1113
val maxPlayerDisplayType: MaxPlayerDisplayType? = MaxPlayerDisplayType.REAL,
1214
val dynamicPlayerRange: Int = 1
1315
)

proxy-shared/src/main/kotlin/app/simplecloud/plugin/proxy/shared/handler/MotdLayoutHandler.kt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ package app.simplecloud.plugin.proxy.shared.handler
33
import app.simplecloud.plugin.proxy.shared.config.GeneralConfig
44
import app.simplecloud.plugin.proxy.shared.config.YamlConfig
55
import app.simplecloud.plugin.proxy.shared.config.motd.MotdLayoutConfiguration
6+
import java.awt.image.BufferedImage
7+
import java.io.ByteArrayOutputStream
68
import java.io.File
9+
import java.util.*
10+
import javax.imageio.ImageIO
11+
712

813
class MotdLayoutHandler(
914
val yamlConfig: YamlConfig,
@@ -24,6 +29,7 @@ class MotdLayoutHandler(
2429
val name = it.nameWithoutExtension
2530
val motdLayout = yamlConfig.load<MotdLayoutConfiguration>("layout/$name")
2631
if (motdLayout != null) {
32+
//motdLayout.serverIcon = convirtImageFileToBase64Url(File(motdLayout.serverIcon))
2733
loadedMotdLayouts[name] = motdLayout
2834
println("Loaded motd layout: $name")
2935
}
@@ -53,4 +59,19 @@ class MotdLayoutHandler(
5359
generalConfig.currentLayout = name
5460
yamlConfig.save("general", generalConfig)
5561
}
62+
63+
/*fun convirtImageFileToBase64Url(imageFile: File): String {
64+
/*if (!imageFile.exists()) {
65+
println("Image file not found: ${imageFile.absolutePath}")
66+
return ""
67+
}
68+
69+
val serverIcon: BufferedImage = ImageIO.read(imageFile)
70+
val outputStream = ByteArrayOutputStream()
71+
ImageIO.write(serverIcon, "png", outputStream)
72+
val iconBytes = outputStream.toByteArray()
73+
return Base64.getEncoder().encodeToString(iconBytes)
74+
*/
75+
return imageFile.name
76+
}*/
5677
}

proxy-velocity/src/main/kotlin/app/simplecloud/plugin/proxy/velocity/ProxyVelocityPlugin.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package app.simplecloud.plugin.proxy.velocity
22

33
import app.simplecloud.plugin.proxy.shared.config.GeneralConfig
44
import app.simplecloud.plugin.proxy.shared.config.YamlConfig
5-
import app.simplecloud.plugin.proxy.shared.config.motd.MotdLayoutConfiguration
65
import app.simplecloud.plugin.proxy.shared.config.placeholder.PlaceHolderConfiguration
76
import app.simplecloud.plugin.proxy.shared.config.tablis.TabListConfiguration
87
import app.simplecloud.plugin.proxy.shared.handler.MotdLayoutHandler

proxy-velocity/src/main/kotlin/app/simplecloud/plugin/proxy/velocity/listener/ProxyPingListener.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,16 @@ import com.velocitypowered.api.event.Subscribe
66
import com.velocitypowered.api.event.proxy.ProxyPingEvent
77
import com.velocitypowered.api.proxy.server.ServerPing
88
import com.velocitypowered.api.proxy.server.ServerPing.SamplePlayer
9+
import com.velocitypowered.api.util.Favicon
10+
import java.awt.image.BufferedImage
11+
import java.io.ByteArrayOutputStream
12+
import java.io.File
913
import java.net.InetAddress
1014
import java.util.*
15+
import javax.imageio.ImageIO
1116
import kotlin.jvm.optionals.getOrNull
1217

18+
1319
class ProxyPingListener(
1420
private val plugin: ProxyVelocityPlugin
1521
) {
@@ -53,12 +59,20 @@ class ProxyPingListener(
5359
)
5460
}
5561

62+
val favicon = if (motdConfiguration.serverIcon == "") {
63+
serverPing.favicon.orElse(null)
64+
} else {
65+
val serverIcon: BufferedImage = ImageIO.read(File(motdConfiguration.serverIcon))
66+
Favicon.create(serverIcon)
67+
}
68+
5669
event.ping = event.ping.asBuilder()
5770
.version(versions)
5871
.onlinePlayers(onlinePlayers)
5972
.maximumPlayers(maxPlayers)
6073
.samplePlayers(*samplePlayers.toTypedArray())
6174
.description(messageOfTheDay)
75+
.favicon(favicon)
6276
.build()
6377
}
6478

0 commit comments

Comments
 (0)