Remove custom Color class and other legacy classes

This commit is contained in:
Norbi Peti 2023-07-24 18:03:17 +02:00
parent cfa9f14b52
commit d42a4a8a70
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
8 changed files with 16 additions and 61 deletions

View file

@ -13,7 +13,6 @@ import buttondevteam.lib.TBMCCoreAPI
import buttondevteam.lib.architecture.ButtonPlugin import buttondevteam.lib.architecture.ButtonPlugin
import buttondevteam.lib.architecture.Component.Companion.registerComponent import buttondevteam.lib.architecture.Component.Companion.registerComponent
import buttondevteam.lib.architecture.ConfigData import buttondevteam.lib.architecture.ConfigData
import buttondevteam.lib.chat.Color
import buttondevteam.lib.chat.TBMCChatAPI import buttondevteam.lib.chat.TBMCChatAPI
import buttondevteam.lib.player.ChromaGamerBase import buttondevteam.lib.player.ChromaGamerBase
import buttondevteam.lib.player.TBMCPlayer import buttondevteam.lib.player.TBMCPlayer
@ -110,18 +109,18 @@ class MainPlugin : ButtonPlugin {
) )
} }
TBMCCoreAPI.RegisterUserClass(TBMCPlayerBase::class.java) { TBMCPlayer() } TBMCCoreAPI.RegisterUserClass(TBMCPlayerBase::class.java) { TBMCPlayer() }
TBMCChatAPI.registerChatChannel(Channel("${ChatColor.WHITE}g${ChatColor.WHITE}", Color.White, "g", null) TBMCChatAPI.registerChatChannel(Channel("${ChatColor.WHITE}g${ChatColor.WHITE}", ChatColor.WHITE, "g", null)
.also { Channel.globalChat = it }) //The /ooc ID has moved to the config .also { Channel.globalChat = it }) //The /ooc ID has moved to the config
TBMCChatAPI.registerChatChannel(Channel( TBMCChatAPI.registerChatChannel(Channel(
"${ChatColor.RED}ADMIN${ChatColor.WHITE}", "${ChatColor.RED}ADMIN${ChatColor.WHITE}",
Color.Red, ChatColor.RED,
"a", "a",
Channel.inGroupFilter(null) Channel.inGroupFilter(null)
) )
.also { Channel.adminChat = it }) .also { Channel.adminChat = it })
TBMCChatAPI.registerChatChannel(Channel( TBMCChatAPI.registerChatChannel(Channel(
"${ChatColor.BLUE}MOD${ChatColor.WHITE}", "${ChatColor.BLUE}MOD${ChatColor.WHITE}",
Color.Blue, ChatColor.BLUE,
"mod", "mod",
Channel.inGroupFilter("mod") Channel.inGroupFilter("mod")
) )
@ -129,17 +128,17 @@ class MainPlugin : ButtonPlugin {
TBMCChatAPI.registerChatChannel( TBMCChatAPI.registerChatChannel(
Channel( Channel(
"${ChatColor.GOLD}DEV${ChatColor.WHITE}", "${ChatColor.GOLD}DEV${ChatColor.WHITE}",
Color.Gold, ChatColor.GOLD,
"dev", "dev",
Channel.inGroupFilter("developer") Channel.inGroupFilter("developer")
) )
) // TODO: Make groups configurable ) // TODO: Make groups configurable
TBMCChatAPI.registerChatChannel(ChatRoom("${ChatColor.RED}RED${ChatColor.WHITE}", Color.DarkRed, "red")) TBMCChatAPI.registerChatChannel(ChatRoom("${ChatColor.RED}RED${ChatColor.WHITE}", ChatColor.DARK_RED, "red"))
TBMCChatAPI.registerChatChannel(ChatRoom("${ChatColor.GOLD}ORANGE${ChatColor.WHITE}", Color.Gold, "orange")) TBMCChatAPI.registerChatChannel(ChatRoom("${ChatColor.GOLD}ORANGE${ChatColor.WHITE}", ChatColor.GOLD, "orange"))
TBMCChatAPI.registerChatChannel(ChatRoom("${ChatColor.YELLOW}YELLOW${ChatColor.WHITE}", Color.Yellow, "yellow")) TBMCChatAPI.registerChatChannel(ChatRoom("${ChatColor.YELLOW}YELLOW${ChatColor.WHITE}", ChatColor.YELLOW, "yellow"))
TBMCChatAPI.registerChatChannel(ChatRoom("${ChatColor.GREEN}GREEN${ChatColor.WHITE}", Color.Green, "green")) TBMCChatAPI.registerChatChannel(ChatRoom("${ChatColor.GREEN}GREEN${ChatColor.WHITE}", ChatColor.GREEN, "green"))
TBMCChatAPI.registerChatChannel(ChatRoom("${ChatColor.AQUA}BLUE${ChatColor.WHITE}", Color.Blue, "blue")) TBMCChatAPI.registerChatChannel(ChatRoom("${ChatColor.AQUA}BLUE${ChatColor.WHITE}", ChatColor.BLUE, "blue"))
TBMCChatAPI.registerChatChannel(ChatRoom("${ChatColor.LIGHT_PURPLE}PURPLE${ChatColor.WHITE}", Color.DarkPurple, "purple")) TBMCChatAPI.registerChatChannel(ChatRoom("${ChatColor.LIGHT_PURPLE}PURPLE${ChatColor.WHITE}", ChatColor.DARK_PURPLE, "purple"))
val playerSupplier = Supplier { Bukkit.getOnlinePlayers().map { obj -> obj.name }.asIterable() } val playerSupplier = Supplier { Bukkit.getOnlinePlayers().map { obj -> obj.name }.asIterable() }
command2MC.addParamConverter( command2MC.addParamConverter(
OfflinePlayer::class.java, OfflinePlayer::class.java,

View file

@ -2,9 +2,9 @@ package buttondevteam.core.component.channel
import buttondevteam.core.ComponentManager.get import buttondevteam.core.ComponentManager.get
import buttondevteam.lib.architecture.IHaveConfig import buttondevteam.lib.architecture.IHaveConfig
import buttondevteam.lib.chat.Color
import buttondevteam.lib.player.ChromaGamerBase import buttondevteam.lib.player.ChromaGamerBase
import org.bukkit.Bukkit import org.bukkit.Bukkit
import org.bukkit.ChatColor
import java.util.* import java.util.*
import java.util.function.Function import java.util.function.Function
import java.util.function.Predicate import java.util.function.Predicate
@ -28,7 +28,7 @@ open class Channel
/** /**
* The default color of the messages sent in the channel * The default color of the messages sent in the channel
*/ */
private val defColor: Color, private val defColor: ChatColor,
/** /**
* The channel identifier. It's the same as the command to be used for the channel *without / *. For example "mod". * The channel identifier. It's the same as the command to be used for the channel *without / *. For example "mod".
* It's also used for scoreboard objective names. * It's also used for scoreboard objective names.
@ -56,7 +56,7 @@ open class Channel
@JvmField @JvmField
val color = component.config.getData( val color = component.config.getData(
"${this.identifier}.color", "${this.identifier}.color",
this.defColor, { c -> Color.valueOf((c as String)) }, Color::toString this.defColor, { c -> ChatColor.getByChar(c as Char) ?: this.defColor }, ChatColor::getChar
) )
@JvmField @JvmField

View file

@ -1,11 +1,11 @@
package buttondevteam.core.component.channel package buttondevteam.core.component.channel
import buttondevteam.lib.TBMCSystemChatEvent import buttondevteam.lib.TBMCSystemChatEvent
import buttondevteam.lib.chat.Color
import buttondevteam.lib.chat.TBMCChatAPI import buttondevteam.lib.chat.TBMCChatAPI
import buttondevteam.lib.player.ChromaGamerBase import buttondevteam.lib.player.ChromaGamerBase
import org.bukkit.ChatColor
class ChatRoom(displayname: String, color: Color, command: String) : Channel( class ChatRoom(displayname: String, color: ChatColor, command: String) : Channel(
displayname, color, command, null // TODO: Custom filter for rooms using abstract method displayname, color, command, null // TODO: Custom filter for rooms using abstract method
) { ) {
private val usersInRoom: MutableList<ChromaGamerBase> = ArrayList() private val usersInRoom: MutableList<ChromaGamerBase> = ArrayList()

View file

@ -1,24 +0,0 @@
package buttondevteam.lib.chat
enum class Color(private val cname: String, val red: Int, val green: Int, val blue: Int) : TellrawSerializableEnum {
Black("black", 0, 0, 0),
DarkBlue("dark_blue", 0, 0, 170),
DarkGreen("dark_green", 0, 170, 0),
DarkAqua("dark_aqua", 0, 170, 170),
DarkRed("dark_red", 170, 0, 0),
DarkPurple("dark_purple", 0, 170, 0),
Gold("gold", 255, 170, 0),
Gray("gray", 170, 170, 170),
DarkGray("dark_gray", 85, 85, 85),
Blue("blue", 85, 85, 255),
Green("green", 85, 255, 85),
Aqua("aqua", 85, 255, 255),
Red("red", 255, 85, 85),
LightPurple("light_purple", 255, 85, 255),
Yellow("yellow", 255, 255, 85),
White("white", 255, 255, 255);
override fun getName(): String {
return cname
}
}

View file

@ -351,7 +351,6 @@ abstract class Command2<TC : ICommand2<TP>, TP : Command2Sender>(
// TODO: Varargs support? (colors?) // TODO: Varargs support? (colors?)
// TODO: Character handling (strlen) // TODO: Character handling (strlen)
// TODO: Param converter
executeInvokeCommand(sd, sender, convertedSender, params) executeInvokeCommand(sd, sender, convertedSender, params)
return 0 return 0

View file

@ -100,7 +100,7 @@ class Command2MC : Command2<ICommand2MC, Command2MCSender>('/', true), Listener
*/ */
private fun permGroup(data: SubcommandData<ICommand2MC, Command2MCSender>): String { private fun permGroup(data: SubcommandData<ICommand2MC, Command2MCSender>): String {
val group = data.annotations.filterIsInstance<MCCommandSettings>().map { val group = data.annotations.filterIsInstance<MCCommandSettings>().map {
if (it.permGroup.isEmpty() && it.modOnly) MCCommandSettings.MOD_GROUP else "" if (it.permGroup.isEmpty() && it.modOnly) MCCommandSettings.MOD_GROUP else "" // TODO: This doesn't seem to return the perm groups themselves
}.firstOrNull() }.firstOrNull()
return group ?: "" return group ?: ""
} }

View file

@ -1,14 +0,0 @@
package buttondevteam.lib.chat;
public enum Priority {
Low(0), Normal(1), High(2);
private final int val;
Priority(int v) {
val = v;
}
public int GetValue() {
return val;
}
}

View file

@ -1,5 +0,0 @@
package buttondevteam.lib.chat;
public interface TellrawSerializableEnum {
String getName();
}