Skip to content
This repository was archived by the owner on Dec 11, 2022. It is now read-only.

Commit

Permalink
Add ChatFormat.java
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaozhangup committed Mar 20, 2022
1 parent b6a23f5 commit 2382718
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/main/java/me/xiaozhangup/natunology/Main.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package me.xiaozhangup.natunology;

import me.xiaozhangup.natunology.commands.Commands;
import me.xiaozhangup.natunology.event.ChatFormat;
import me.xiaozhangup.natunology.event.MovePart;
import me.xiaozhangup.natunology.techcore.api.Test;
import me.xiaozhangup.natunology.techcore.events.Books;
Expand All @@ -27,6 +28,12 @@ public void onEnable() {
getLogger().info("Step Loaded!");
}

if (getConfig().getBoolean("ChatFormat.enable")) {
MovePart.runStep();
Bukkit.getPluginManager().registerEvents(new ChatFormat(), this);
getLogger().info("ChatFormat Loaded!");
}

Commands.regCommands();
getLogger().info("Commands Loaded!");

Expand Down
18 changes: 18 additions & 0 deletions src/main/java/me/xiaozhangup/natunology/event/ChatFormat.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package me.xiaozhangup.natunology.event;

import me.xiaozhangup.natunology.Main;
import me.xiaozhangup.natunology.api.Message;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;

public class ChatFormat implements Listener {

@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerChat(AsyncPlayerChatEvent e) {
if (e.isCancelled()) return;
e.setFormat(Main.plugin.getConfig().getString("ChatFormat").replace("&" , Message.getCode()).replace("{MESSAGE}" , e.getMessage()));
}

}
3 changes: 3 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Step:
enable: false
size: 1.05
ChatFormat:
enable: false
format: "[level] [tag] [me] > §x§f§5§f§5§f§5{MESSAGE}"
#我们禁用了这些功能于源代码
#Dead:
# enable: true
Expand Down

0 comments on commit 2382718

Please sign in to comment.