Fix player config stuff and test event stuff
- The chat tests work!
This commit is contained in:
parent
4f0e05892a
commit
ddd24a73f6
5 changed files with 13 additions and 16 deletions
|
@ -29,13 +29,13 @@ class PlayerListener(val plugin: MainPlugin) : Listener {
|
|||
fun onPlayerJoin(event: PlayerJoinEvent) {
|
||||
val p = event.player
|
||||
val player = TBMCPlayerBase.getPlayer(p.uniqueId, TBMCPlayer::class.java)
|
||||
val pname = player.playerName.get()
|
||||
val pname = player.playerName
|
||||
if (pname.isEmpty()) {
|
||||
player.playerName.set(p.name)
|
||||
plugin.logger.info("Player name saved: " + player.playerName.get())
|
||||
player.playerName = p.name
|
||||
plugin.logger.info("Player name saved: " + player.playerName)
|
||||
} else if (p.name != pname) {
|
||||
plugin.logger.info(pname + " renamed to " + p.name)
|
||||
player.playerName.set(p.name)
|
||||
player.playerName = p.name
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,8 +19,7 @@ import java.util.stream.Collectors
|
|||
abstract class Component<TP : JavaPlugin> {
|
||||
var isEnabled = false
|
||||
|
||||
var config: IHaveConfig = IHaveConfig({ logWarn("Attempted to save config with null section!") }, null)
|
||||
private set
|
||||
val config: IHaveConfig = IHaveConfig({ logWarn("Attempted to save config with null section!") }, null)
|
||||
lateinit var plugin: TP
|
||||
private set
|
||||
|
||||
|
|
|
@ -17,12 +17,11 @@ import java.util.function.Supplier
|
|||
|
||||
@ChromaGamerEnforcer
|
||||
abstract class ChromaGamerBase : Command2Sender {
|
||||
lateinit var config: IHaveConfig
|
||||
protected set
|
||||
val config: IHaveConfig = IHaveConfig({ save() }, null)
|
||||
|
||||
protected lateinit var commonUserData: CommonUserData<out ChromaGamerBase>
|
||||
protected open fun initConfig() {
|
||||
config = IHaveConfig({ save() }, commonUserData.playerData)
|
||||
config.reload(commonUserData.playerData)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,7 +2,6 @@ package buttondevteam.lib.player
|
|||
|
||||
import buttondevteam.core.MainPlugin
|
||||
import buttondevteam.core.component.channel.Channel
|
||||
import buttondevteam.lib.architecture.IHaveConfig
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.entity.Player
|
||||
import java.util.*
|
||||
|
@ -17,10 +16,9 @@ abstract class TBMCPlayerBase : ChromaGamerBase() {
|
|||
/**
|
||||
* If the player is the console
|
||||
*/
|
||||
val isConsole = uniqueId == UUID(0, 0)
|
||||
val isConsole by lazy { uniqueId == UUID(0, 0) }
|
||||
|
||||
@JvmField
|
||||
val playerName = super.config.getData("PlayerName", "")
|
||||
var playerName by super.config.getData("PlayerName", "")
|
||||
public override fun initConfig() {
|
||||
super.initConfig()
|
||||
val pluginName = if (javaClass.isAnnotationPresent(PlayerClass::class.java))
|
||||
|
@ -29,7 +27,7 @@ abstract class TBMCPlayerBase : ChromaGamerBase() {
|
|||
throw RuntimeException("Class not defined as player class! Use @PlayerClass")
|
||||
val playerData = commonUserData.playerData
|
||||
val section = playerData.getConfigurationSection(pluginName) ?: playerData.createSection(pluginName)
|
||||
config = IHaveConfig({ save() }, section)
|
||||
config.reload(section)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -55,7 +53,7 @@ abstract class TBMCPlayerBase : ChromaGamerBase() {
|
|||
}
|
||||
|
||||
override fun getName(): String {
|
||||
return player?.displayName ?: playerName.get()
|
||||
return player?.displayName ?: playerName
|
||||
}
|
||||
|
||||
override fun checkChannelInGroup(group: String?): Channel.RecipientTestResult {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package buttondevteam.lib.player;
|
||||
|
||||
import buttondevteam.lib.ChromaUtils;
|
||||
import buttondevteam.lib.player.ChromaGamerBase.InfoTarget;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
@ -24,7 +25,7 @@ public class TBMCPlayerGetInfoEvent extends Event {
|
|||
private final InfoTarget target;
|
||||
|
||||
TBMCPlayerGetInfoEvent(ChromaGamerBase player, InfoTarget target) {
|
||||
super(true);
|
||||
super(!ChromaUtils.isTest());
|
||||
this.player = player;
|
||||
infolines = new ArrayList<>();
|
||||
this.target = target;
|
||||
|
|
Loading…
Reference in a new issue