-
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
YufiriaMazenta
committed
Jul 31, 2024
1 parent
70c33c3
commit 3d2510d
Showing
20 changed files
with
487 additions
and
243 deletions.
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
56 changes: 56 additions & 0 deletions
56
src/main/java/pers/yufiria/deathmsg/event/DeathMessageSendEvent.java
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,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
37
src/main/kotlin/com/github/yufiriamazenta/deathmsg/DeathMessage.kt
This file was deleted.
Oops, something went wrong.
29 changes: 0 additions & 29 deletions
29
src/main/kotlin/com/github/yufiriamazenta/deathmsg/commands/DeathMessageReloadCommand.kt
This file was deleted.
Oops, something went wrong.
68 changes: 0 additions & 68 deletions
68
src/main/kotlin/com/github/yufiriamazenta/deathmsg/commands/FilterDeathMessageCmd.kt
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
src/main/kotlin/com/github/yufiriamazenta/deathmsg/util/LangUtil.kt
This file was deleted.
Oops, something went wrong.
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,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?)!! |
27 changes: 27 additions & 0 deletions
27
src/main/kotlin/pers/yufiria/deathmsg/commands/DeathMessageReloadCommand.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,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()) | ||
} | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
src/main/kotlin/pers/yufiria/deathmsg/commands/FilterDeathMessageCmd.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,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("") | ||
} | ||
} | ||
} | ||
|
||
|
||
} |
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,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已关闭死亡消息屏蔽") | ||
|
||
} |
Oops, something went wrong.