Commit 4ada3819 authored by Linus K.'s avatar Linus K.
Browse files

Add autocolor for signs

parent 82b0bf29
Pipeline #123 failed with stage
in 2 minutes and 2 seconds
......@@ -47,6 +47,7 @@ class Plugin: JavaPlugin() {
fun registerListeners() {
val pm = Bukkit.getPluginManager()
pm.registerEvents(AutoFarmerListener(), this)
pm.registerEvents(ColoredSignsListener(), this)
}
fun registerSchedulers() {
......
package me.linuscde.mcplugins.autosyston.listeners
import org.bukkit.ChatColor
import org.bukkit.event.EventHandler
import org.bukkit.event.Listener
import org.bukkit.event.block.SignChangeEvent
class ColoredSignsListener: Listener {
@EventHandler
fun onSignChange(e: SignChangeEvent) {
// Don't color if this might be a prefix of a custom plugin
if(e.getLine(0)?.contains("[") == true && e.getLine(0)?.contains("]") == true)
return
if(e.getLine(0)?.contains("<") == true && e.getLine(0)?.contains(">") == true)
return
// Color lines
for(i in 0..3) {
val line = e.getLine(i) ?: continue
if('&' in line)
e.setLine(i, ChatColor.translateAlternateColorCodes('&', line));
}
}
}
\ No newline at end of file
......@@ -16,7 +16,7 @@
<maven.compiler.target>1.8</maven.compiler.target>
<revision>0.1.0-SNAPSHOT</revision>
<mcplugins.autosyston.version>0.1.0</mcplugins.autosyston.version>
<mcplugins.autosyston.version>0.2.0</mcplugins.autosyston.version>
<mcplugins.kotlin.version>1.0.0</mcplugins.kotlin.version>
<mcplugins.teleportastic.version>0.3.0</mcplugins.teleportastic.version>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment