-
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.
- Loading branch information
Showing
10 changed files
with
81 additions
and
1 deletion.
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
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
11 changes: 11 additions & 0 deletions
11
src/main/java/dev/mikchan/mcnp/motd/formatter/creator/FormatterCreator.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package dev.mikchan.mcnp.motd.formatter.creator | ||
|
||
import dev.mikchan.mcnp.motd.MOTDPlugin | ||
import dev.mikchan.mcnp.motd.formatter.formatter.Formatter | ||
import dev.mikchan.mcnp.motd.formatter.formatter.IFormatter | ||
|
||
internal class FormatterCreator : IFormatterCreator { | ||
override fun build(plugin: MOTDPlugin): IFormatter { | ||
return Formatter() | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/dev/mikchan/mcnp/motd/formatter/creator/IFormatterCreator.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package dev.mikchan.mcnp.motd.formatter.creator | ||
|
||
import dev.mikchan.mcnp.motd.MOTDPlugin | ||
import dev.mikchan.mcnp.motd.formatter.formatter.IFormatter | ||
|
||
interface IFormatterCreator { | ||
fun build(plugin: MOTDPlugin): IFormatter | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/dev/mikchan/mcnp/motd/formatter/creator/papi/PapiFormatterCreator.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package dev.mikchan.mcnp.motd.formatter.creator.papi | ||
|
||
import dev.mikchan.mcnp.motd.MOTDPlugin | ||
import dev.mikchan.mcnp.motd.formatter.creator.IFormatterCreator | ||
import dev.mikchan.mcnp.motd.formatter.formatter.IFormatter | ||
import dev.mikchan.mcnp.motd.formatter.formatter.papi.PapiFormatter | ||
import me.clip.placeholderapi.PlaceholderAPIPlugin | ||
|
||
internal class PapiFormatterCreator(private val fallback: IFormatterCreator) : IFormatterCreator { | ||
override fun build(plugin: MOTDPlugin): IFormatter { | ||
val papi = plugin.server.pluginManager.getPlugin("PlaceholderAPI") as? PlaceholderAPIPlugin? | ||
return papi?.let { | ||
plugin.logger.info("PlaceholderAPI found! Hooking in...") | ||
PapiFormatter() | ||
} ?: fallback.build(plugin) | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/dev/mikchan/mcnp/motd/formatter/formatter/Formatter.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package dev.mikchan.mcnp.motd.formatter.formatter | ||
|
||
import org.bukkit.ChatColor | ||
import org.bukkit.OfflinePlayer | ||
|
||
internal class Formatter : IFormatter { | ||
override fun format(str: String, player: OfflinePlayer?): String { | ||
return ChatColor.translateAlternateColorCodes('&', str) | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/dev/mikchan/mcnp/motd/formatter/formatter/IFormatter.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package dev.mikchan.mcnp.motd.formatter.formatter | ||
|
||
import org.bukkit.OfflinePlayer | ||
|
||
interface IFormatter { | ||
fun format(str: String, player: OfflinePlayer? = null): String | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/dev/mikchan/mcnp/motd/formatter/formatter/papi/PapiFormatter.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package dev.mikchan.mcnp.motd.formatter.formatter.papi | ||
|
||
import dev.mikchan.mcnp.motd.formatter.formatter.IFormatter | ||
import me.clip.placeholderapi.PlaceholderAPI | ||
import org.bukkit.ChatColor | ||
import org.bukkit.OfflinePlayer | ||
|
||
internal class PapiFormatter : IFormatter { | ||
override fun format(str: String, player: OfflinePlayer?): String { | ||
val format = PlaceholderAPI.setPlaceholders(player, str) | ||
return ChatColor.translateAlternateColorCodes('&', format) | ||
} | ||
} |
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