Skip to content

Commit

Permalink
实现热重载
Browse files Browse the repository at this point in the history
修复铁砧颜色的BUG
统一一下@ALL 和 ping的声音
  • Loading branch information
MineSunshineone committed Jan 23, 2025
1 parent 6811efd commit 6deafe0
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 7 deletions.
2 changes: 1 addition & 1 deletion dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>ict.MineSunshineone</groupId>
<artifactId>SimpleChat</artifactId>
<version>1.5</version>
<version>1.6</version>
<build>
<resources>
<resource>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<groupId>ict.MineSunshineone</groupId>
<artifactId>SimpleChat</artifactId>
<version>1.5</version>
<version>1.6</version>

<repositories>
<repository>
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/ict/minesunshineone/chat/SimpleChat.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.bukkit.plugin.java.JavaPlugin;

import ict.minesunshineone.chat.commands.MuteCommand;
import ict.minesunshineone.chat.commands.ReloadCommand;
import ict.minesunshineone.chat.listeners.AnvilListener;
import ict.minesunshineone.chat.listeners.PingListener;
import ict.minesunshineone.chat.listeners.PlayerChatListener;
Expand Down Expand Up @@ -31,6 +32,7 @@ public void onEnable() {
getCommand("unmute").setExecutor(muteCommand);
getCommand("mute").setTabCompleter(muteCommand);
getCommand("unmute").setTabCompleter(muteCommand);
getCommand("chatreload").setExecutor(new ReloadCommand(this));

getLogger().info("SimpleChat插件已启用");
}
Expand Down
25 changes: 25 additions & 0 deletions src/main/java/ict/minesunshineone/chat/commands/ReloadCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package ict.minesunshineone.chat.commands;

import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

import ict.minesunshineone.chat.SimpleChat;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.TextColor;

public class ReloadCommand implements CommandExecutor {

private final SimpleChat plugin;

public ReloadCommand(SimpleChat plugin) {
this.plugin = plugin;
}

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
plugin.reloadConfig();
sender.sendMessage(Component.text("SimpleChat配置已重载!").color(TextColor.color(255, 170, 0)));
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public void onAnvilPrepare(PrepareAnvilEvent event) {
return;
}

Component name = meta.displayName();
Component coloredName = ComponentUtils.legacySerializer().deserialize(name.toString())
String name = meta.getDisplayName();
Component coloredName = ComponentUtils.legacySerializer().deserialize(name)
.decoration(TextDecoration.ITALIC, false);

meta.displayName(coloredName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void onAsyncChat(AsyncChatEvent event) {

// 给所有在线玩家发送提醒(除了发送者)
for (Player target : plugin.getServer().getOnlinePlayers()) {
target.playSound(target.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 1.0f, 1.0f);
target.playSound(target.getLocation(), Sound.BLOCK_ANVIL_LAND, 2.0f, 1.0f);
Component actionBar = Component.text("管理员 ")
.append(Component.text(sender.getName()).color(NamedTextColor.YELLOW))
.append(Component.text(" 发送了全体消息!"));
Expand All @@ -102,7 +102,7 @@ public void onAsyncChat(AsyncChatEvent event) {
.build());

if (!sender.equals(target)) {
target.playSound(target.getLocation(), Sound.BLOCK_ANVIL_LAND, 2.5f, 1.0f);
target.playSound(target.getLocation(), Sound.BLOCK_ANVIL_LAND, 2.0f, 1.0f);
Component actionBar = PLAYER_MENTION_PREFIX
.append(Component.text(sender.getName()).color(NamedTextColor.YELLOW))
.append(PLAYER_MENTION_SUFFIX);
Expand Down
9 changes: 8 additions & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ permissions:
simplechat.mute:
description: 允许使用禁言和解除禁言命令
default: op
simplechat.reload:
description: 允许重载聊天插件配置
default: op

commands:
mute:
Expand All @@ -33,4 +36,8 @@ commands:
unmute:
description: 解除玩家禁言
usage: /unmute <玩家>
permission: simplechat.mute
permission: simplechat.mute
chatreload:
description: 重载聊天插件配置
usage: /chatreload
permission: simplechat.reload

0 comments on commit 6deafe0

Please sign in to comment.