mirror of
https://github.com/kaboomserver/commandspy.git
synced 2024-06-09 22:04:58 +00:00
Compare commits
2 commits
308652bfd0
...
b7f20a595a
Author | SHA1 | Date | |
---|---|---|---|
b7f20a595a | |||
5933691f8c |
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
|
@ -15,7 +15,7 @@ jobs:
|
||||||
- uses: actions/setup-java@v2
|
- uses: actions/setup-java@v2
|
||||||
with:
|
with:
|
||||||
distribution: 'temurin'
|
distribution: 'temurin'
|
||||||
java-version: 8
|
java-version: 17
|
||||||
|
|
||||||
- name: Cache maven packages to speed up build
|
- name: Cache maven packages to speed up build
|
||||||
uses: actions/cache@v1
|
uses: actions/cache@v1
|
||||||
|
|
9
pom.xml
9
pom.xml
|
@ -5,17 +5,18 @@
|
||||||
<version>master</version>
|
<version>master</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
<maven.test.skip>true</maven.test.skip>
|
<maven.test.skip>true</maven.test.skip>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.destroystokyo.paper</groupId>
|
<groupId>io.papermc.paper</groupId>
|
||||||
<artifactId>paper-api</artifactId>
|
<artifactId>paper-api</artifactId>
|
||||||
<version>1.13.2-R0.1-SNAPSHOT</version>
|
<version>1.18.2-R0.1-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
@ -17,6 +16,8 @@ import org.bukkit.event.block.SignChangeEvent;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
|
||||||
public final class Main extends JavaPlugin implements CommandExecutor, Listener {
|
public final class Main extends JavaPlugin implements CommandExecutor, Listener {
|
||||||
private FileConfiguration config;
|
private FileConfiguration config;
|
||||||
|
@ -31,27 +32,27 @@ public final class Main extends JavaPlugin implements CommandExecutor, Listener
|
||||||
private void enableCommandSpy(final Player player) {
|
private void enableCommandSpy(final Player player) {
|
||||||
config.set(player.getUniqueId().toString(), true);
|
config.set(player.getUniqueId().toString(), true);
|
||||||
saveConfig();
|
saveConfig();
|
||||||
player.sendMessage("Successfully enabled CommandSpy");
|
player.sendMessage(Component.text("Successfully enabled CommandSpy"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void disableCommandSpy(final Player player) {
|
private void disableCommandSpy(final Player player) {
|
||||||
config.set(player.getUniqueId().toString(), null);
|
config.set(player.getUniqueId().toString(), null);
|
||||||
saveConfig();
|
saveConfig();
|
||||||
player.sendMessage("Successfully disabled CommandSpy");
|
player.sendMessage(Component.text("Successfully disabled CommandSpy"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private ChatColor getChatColor(final Player player) {
|
private NamedTextColor getTextColor(final Player player) {
|
||||||
if (config.contains(player.getUniqueId().toString())) {
|
if (config.contains(player.getUniqueId().toString())) {
|
||||||
return ChatColor.YELLOW;
|
return NamedTextColor.YELLOW;
|
||||||
}
|
}
|
||||||
return ChatColor.AQUA;
|
return NamedTextColor.AQUA;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(final CommandSender sender, final Command cmd, final String label,
|
public boolean onCommand(final CommandSender sender, final Command cmd, final String label,
|
||||||
final String[] args) {
|
final String[] args) {
|
||||||
if (sender instanceof ConsoleCommandSender) {
|
if (sender instanceof ConsoleCommandSender) {
|
||||||
sender.sendMessage("Command has to be run by a player");
|
sender.sendMessage(Component.text("Command has to be run by a player"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,8 +78,10 @@ public final class Main extends JavaPlugin implements CommandExecutor, Listener
|
||||||
}
|
}
|
||||||
|
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final ChatColor color = getChatColor(player);
|
final NamedTextColor color = getTextColor(player);
|
||||||
final String message = color + player.getName() + color + ": " + event.getMessage();
|
final Component message = Component.text(player.getName(), color)
|
||||||
|
.append(Component.text(": "))
|
||||||
|
.append(Component.text(event.getMessage()));
|
||||||
|
|
||||||
for (String uuidString : config.getKeys(false)) {
|
for (String uuidString : config.getKeys(false)) {
|
||||||
final UUID uuid = UUID.fromString(uuidString);
|
final UUID uuid = UUID.fromString(uuidString);
|
||||||
|
@ -94,9 +97,15 @@ public final class Main extends JavaPlugin implements CommandExecutor, Listener
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onSignChange(final SignChangeEvent event) {
|
void onSignChange(final SignChangeEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final ChatColor color = getChatColor(player);
|
final NamedTextColor color = getTextColor(player);
|
||||||
final String message = color + player.getName() + color
|
Component message = Component.text(player.getName(), color)
|
||||||
+ " created a sign with contents:";
|
.append(Component.text(" created a sign with contents:"));
|
||||||
|
|
||||||
|
for (Component line : event.lines()) {
|
||||||
|
message = message
|
||||||
|
.append(Component.text("\n "))
|
||||||
|
.append(line);
|
||||||
|
}
|
||||||
|
|
||||||
for (String uuidString : config.getKeys(false)) {
|
for (String uuidString : config.getKeys(false)) {
|
||||||
final UUID uuid = UUID.fromString(uuidString);
|
final UUID uuid = UUID.fromString(uuidString);
|
||||||
|
@ -106,10 +115,6 @@ public final class Main extends JavaPlugin implements CommandExecutor, Listener
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
recipient.sendMessage(message);
|
recipient.sendMessage(message);
|
||||||
|
|
||||||
for (String line : event.getLines()) {
|
|
||||||
recipient.sendMessage(color + " " + line);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue