Skip to content

Commit e9e5dfd

Browse files
authored
Add files via upload
0 parents  commit e9e5dfd

5 files changed

Lines changed: 138 additions & 0 deletions

File tree

pom.xml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>theoni.splitchat</groupId>
6+
<artifactId>splitchat</artifactId>
7+
<version>1.0</version>
8+
9+
<name>SplitChat</name>
10+
11+
<properties>
12+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
13+
<maven.compiler.source>1.8</maven.compiler.source>
14+
<maven.compiler.target>1.8</maven.compiler.target>
15+
</properties>
16+
17+
<repositories>
18+
<repository>
19+
<id>nukkitx-repo</id>
20+
<url>https://repo.nukkitx.com/snapshot/</url>
21+
</repository>
22+
</repositories>
23+
24+
<dependencies>
25+
<dependency>
26+
<groupId>cn.nukkit</groupId>
27+
<artifactId>nukkit</artifactId>
28+
<version>1.0-SNAPSHOT</version>
29+
<scope>provided</scope>
30+
</dependency>
31+
</dependencies>
32+
33+
<build>
34+
<defaultGoal>clean package</defaultGoal>
35+
<finalName>${project.name}</finalName>
36+
<sourceDirectory>src/main/java</sourceDirectory>
37+
<resources>
38+
<resource>
39+
<filtering>true</filtering>
40+
<directory>src/main/resources/</directory>
41+
</resource>
42+
</resources>
43+
</build>
44+
</project>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package theoni.splitchat;
2+
3+
import cn.nukkit.event.Listener;
4+
import cn.nukkit.plugin.PluginBase;
5+
import cn.nukkit.plugin.PluginManager;
6+
import theoni.splitchat.listener.*;
7+
8+
public class Main extends PluginBase implements Listener {
9+
10+
public void onEnable() {
11+
this.saveDefaultConfig();
12+
this.getServer().getPluginManager().registerEvents((Listener)new EventListener(this), (Main)this);
13+
this.checkChatPlugin();
14+
}
15+
16+
public void checkChatPlugin() {
17+
PluginManager mgr = this.getServer().getPluginManager();
18+
if (mgr.getPlugin("LuckChat") != null) {
19+
this.getServer().getLogger().warning("If you are using LuckChat for the chat format for the plugin to work properly, go to config.yml and change the ChatAsync parameter to false");
20+
}
21+
}
22+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package theoni.splitchat.listener;
2+
3+
import cn.nukkit.Player;
4+
import cn.nukkit.event.EventHandler;
5+
import cn.nukkit.event.Listener;
6+
import cn.nukkit.event.player.PlayerChatEvent;
7+
import cn.nukkit.utils.Config;
8+
import theoni.splitchat.Main;
9+
10+
public class EventListener implements Listener {
11+
12+
Main plugin;
13+
Config config;
14+
Config mobs;
15+
16+
public EventListener(Main plugin) {
17+
this.plugin = plugin;
18+
this.config = plugin.getConfig();
19+
}
20+
21+
@EventHandler
22+
public void onChat(PlayerChatEvent event) {
23+
Player player = event.getPlayer();
24+
String message = event.getMessage();
25+
if (!event.isCancelled()) {
26+
if (message.substring(0, 1).contains(config.getString("symbol"))) {
27+
String format = event.getFormat()
28+
.replaceFirst(config.getString("symbol"), "")
29+
.replace("%splitchat_prefix%", config.getString("prefix.global"));
30+
for (Player players : plugin.getServer().getOnlinePlayers().values()) {
31+
players.sendMessage(format);
32+
plugin.getServer().getLogger().info(format);
33+
}
34+
event.setCancelled();
35+
} else {
36+
for (Player players : plugin.getServer().getOnlinePlayers().values()) {
37+
if (player.distance(players) <= config.getInt("distance")) {
38+
String format = event.getFormat()
39+
.replace("%splitchat_prefix%", config.getString("prefix.local"));
40+
players.sendMessage(format);
41+
plugin.getServer().getLogger().info(format);
42+
}
43+
}
44+
event.setCancelled();
45+
}
46+
}
47+
}
48+
}

src/main/resources/config.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Distance at which the local message will be visible
2+
radius: 100
3+
4+
# The symbol for sending a message to the global chat.
5+
# Example: "!your message"
6+
symbol: "!"
7+
8+
# Prefix for local and global chat
9+
# Example: "L | MEFRREEXX: your message"
10+
prefix:
11+
local: "§l§aL §8|§r"
12+
global: "§l§cG §8|§r"

src/main/resources/plugin.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: ${project.name}
2+
version: ${project.version}
3+
api: ["1.0.8"]
4+
author: The Oni
5+
description: ${project.description}
6+
main: theoni.splitchat.Main
7+
8+
permissions:
9+
debugtool.use:
10+
default: op
11+
debugtool.about:
12+
default: true

0 commit comments

Comments
 (0)