Skip to content

Commit

Permalink
[1.4.0-beta1]重构部分代码,新增跨服功能
Browse files Browse the repository at this point in the history
  • Loading branch information
YufiriaMazenta committed Jul 31, 2024
1 parent 70c33c3 commit 3d2510d
Show file tree
Hide file tree
Showing 20 changed files with 487 additions and 243 deletions.
14 changes: 7 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ plugins {
kotlin("jvm") version "1.9.20"
}

group = "com.github.yufiriamazenta"
version = "1.3.2"
group = "pers.yufiria"
version = "1.4.0-beta1"

repositories {
mavenLocal()
Expand All @@ -32,7 +32,7 @@ dependencies {
compileOnly("me.clip:placeholderapi:2.11.1")
compileOnly("io.lumine:Mythic-Dist:5.3.5")
compileOnly("io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT")
implementation("com.crypticlib:common:0.18.10")
implementation("com.crypticlib:bukkit:1.1.5")
implementation(kotlin("stdlib-jdk8"))
}

Expand All @@ -59,10 +59,10 @@ tasks {
}
shadowJar {
archiveFileName.set("DeathMessage-$version.jar")
relocate("crypticlib", "com.github.yufiriamazenta.deathmsg.crypticlib")
relocate("kotlin", "com.github.yufiriamazenta.deathmsg.libs.kotlin")
relocate("org.intellij.lang.annotations", "com.github.yufiriamazenta.deathmsg.libs.intellij.lang.annotations")
relocate("org.jetbrains.annotations", "com.github.yufiriamazenta.deathmsg.libs.jetbrains.annotations")
relocate("crypticlib", "pers.yufiria.deathmsg.crypticlib")
relocate("kotlin", "pers.yufiria.deathmsg.libs.kotlin")
relocate("org.intellij.lang.annotations", "pers.yufiria.deathmsg.libs.intellij.lang.annotations")
relocate("org.jetbrains.annotations", "pers.yufiria.deathmsg.libs.jetbrains.annotations")
}
}
kotlin {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package pers.yufiria.deathmsg.event;

import net.kyori.adventure.text.Component;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class DeathMessageSendEvent extends Event implements Cancellable {

private Component deathMessage;
private final Player deadPlayer;
private boolean cancelled;

public DeathMessageSendEvent(@NotNull Component deathMessage, @Nullable Player deadPlayer) {
this.deathMessage = deathMessage;
this.deadPlayer = deadPlayer;
}

public @NotNull Component deathMessage() {
return deathMessage;
}

public DeathMessageSendEvent setDeathMessage(@NotNull Component deathMessage) {
this.deathMessage = deathMessage;
return this;
}

public @Nullable Player deadPlayer() {
return deadPlayer;
}

@Override
public boolean isCancelled() {
return cancelled;
}

@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}

private static final HandlerList handlers = new HandlerList();

public static HandlerList getHandlerList() {
return handlers;
}

@Override
public @NotNull HandlerList getHandlers() {
return handlers;
}

}
37 changes: 0 additions & 37 deletions src/main/kotlin/com/github/yufiriamazenta/deathmsg/DeathMessage.kt

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

24 changes: 24 additions & 0 deletions src/main/kotlin/pers/yufiria/deathmsg/DeathMessage.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package pers.yufiria.deathmsg

import pers.yufiria.deathmsg.config.DeathMessages
import crypticlib.BukkitPlugin
import crypticlib.chat.BukkitMsgSender
import org.bukkit.Bukkit
import org.bukkit.NamespacedKey
import org.bukkit.entity.Player
import org.bukkit.persistence.PersistentDataType

class DeathMessage: BukkitPlugin() {


override fun enable() {
BukkitMsgSender.INSTANCE.info("[DeathMessage] DeathMessage Enabled")
}

override fun disable() {
BukkitMsgSender.INSTANCE.info("[DeathMessage] DeathMessage Disabled")
}

}

val DEATH_MESSAGE: DeathMessage = (Bukkit.getPluginManager().getPlugin("DeathMessage") as DeathMessage?)!!
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package pers.yufiria.deathmsg.commands

import crypticlib.chat.BukkitMsgSender
import crypticlib.command.BukkitCommand
import crypticlib.command.CommandInfo
import crypticlib.command.annotation.Command
import crypticlib.perm.PermInfo
import org.bukkit.command.CommandSender
import org.bukkit.entity.Player
import pers.yufiria.deathmsg.DEATH_MESSAGE
import pers.yufiria.deathmsg.config.Configs

@Command
object DeathMessageReloadCommand : BukkitCommand(CommandInfo("deathmessagereload", PermInfo("deathmessage.command.reload"), mutableListOf("dmrl"))) {

override fun execute(sender: CommandSender, args: MutableList<String>) {
if (args.isNotEmpty()) {
return
}
if (sender is Player && !sender.isOp()) {
return
}
DEATH_MESSAGE.reloadPlugin()
BukkitMsgSender.INSTANCE.sendMsg(sender, Configs.pluginMessageCommandReload.value())
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package pers.yufiria.deathmsg.commands

import crypticlib.chat.BukkitMsgSender
import crypticlib.command.BukkitCommand
import pers.yufiria.deathmsg.DEATH_MESSAGE
import crypticlib.command.CommandHandler
import crypticlib.command.CommandInfo
import crypticlib.command.annotation.Command
import crypticlib.perm.PermInfo
import org.bukkit.command.CommandSender
import org.bukkit.entity.Player
import org.bukkit.persistence.PersistentDataType
import pers.yufiria.deathmsg.config.Configs
import pers.yufiria.deathmsg.util.PlayerUtil

@Command
object FilterDeathMessageCmd : BukkitCommand(CommandInfo("deathmessagefilter", PermInfo("deathmessage.command.filter"), mutableListOf("dmf"))) {

override fun execute(sender: CommandSender, args: MutableList<String>) {
if (sender !is Player) {
BukkitMsgSender.INSTANCE.sendMsg(sender, Configs.pluginMessagePlayerOnly.value())
return
}
if (args.isEmpty()) {
PlayerUtil.toggleFilter(sender)
} else {
when (args[0]) {
"on" -> PlayerUtil.setFilterOn(sender)
"off" -> PlayerUtil.setFilterOff(sender)
else -> PlayerUtil.toggleFilter(sender)
}
}
return
}

override fun tab(sender: CommandSender, args: MutableList<String>): MutableList<String> {
return when (args.size) {
0, 1 -> {
val list: MutableList<String> = mutableListOf("off", "on")
list.removeIf { str: String -> !str.startsWith(args[0]) }
list
}

else -> {
mutableListOf("")
}
}
}


}
20 changes: 20 additions & 0 deletions src/main/kotlin/pers/yufiria/deathmsg/config/Configs.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package pers.yufiria.deathmsg.config

import crypticlib.config.ConfigHandler
import crypticlib.config.node.impl.bukkit.BooleanConfig
import crypticlib.config.node.impl.bukkit.ConfigSectionConfig
import crypticlib.config.node.impl.bukkit.StringConfig

@ConfigHandler(path = "config.yml")
object Configs {

@JvmStatic val proxy = BooleanConfig("proxy", false)
@JvmStatic val playerNameFormat = StringConfig("player_name_format", "%player_displayname%")
@JvmStatic val deathMessageType = StringConfig("death_message_type", "chat")
@JvmStatic val deathMessages = ConfigSectionConfig("death_message")
@JvmStatic val pluginMessageCommandReload = StringConfig("plugin_message.command_reload", "&a插件重载完毕")
@JvmStatic val pluginMessagePlayerOnly = StringConfig("plugin_message.player_only", "&c只有玩家才能使用此命令")
@JvmStatic val pluginMessageFilterOn = StringConfig("plugin_message.filter_on", "&a已开启死亡消息屏蔽")
@JvmStatic val pluginMessageFilterOff = StringConfig("plugin_message.filter_off", "&a已关闭死亡消息屏蔽")

}
Loading

0 comments on commit 3d2510d

Please sign in to comment.