Fix compilation and improve some features

This commit is contained in:
Draycia committed 2020-07-12 06:08:28 -07:00
1 parent ad8089855c
commit 2fb1eb0eb5
14 files changed
+45 -116

No files matched your search

+15 -45
View File
@@ -7,7 +7,7 @@
<parent>
<artifactId>SimpleChatParent</artifactId>
<groupId>net.draycia</groupId>
<version>1.0-SNAPSHOT</version>
<version>1.0</version>
</parent>
<artifactId>SimpleChatModeration</artifactId>
@@ -24,48 +24,6 @@
<version>3.1.1</version>
<configuration>
<dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>
<relocations>
<relocation>
<pattern>co.aikar.commands</pattern>
<shadedPattern>net.draycia.simplechat.libs.acf</shadedPattern>
</relocation>
<relocation>
<pattern>co.aikar.locales</pattern>
<shadedPattern>net.draycia.simplechat.libs.locales</shadedPattern>
</relocation>
<relocation>
<pattern>co.aikar.idb</pattern>
<shadedPattern>net.draycia.simplechat.libs.idb</shadedPattern>
</relocation>
<relocation>
<pattern>net.kyori</pattern>
<shadedPattern>net.draycia.simplechat.libs.kyori</shadedPattern>
</relocation>
<relocation>
<pattern>io.papermc.lib</pattern>
<shadedPattern>net.draycia.simplechat.libs.paperlib</shadedPattern>
</relocation>
<relocation>
<pattern>com.fasterxml</pattern>
<shadedPattern>net.draycia.simplechat.libs.fasterxml</shadedPattern>
</relocation>
<relocation>
<pattern>com.neovisionaries</pattern>
<shadedPattern>net.draycia.simplechat.libs.neovisionaries</shadedPattern>
</relocation>
<relocation>
<pattern>okio</pattern>
<shadedPattern>net.draycia.simplechat.libs.okio</shadedPattern>
</relocation>
<relocation>
<pattern>okhttp3</pattern>
<shadedPattern>net.draycia.simplechat.libs.okhttp3</shadedPattern>
</relocation>
<relocation>
<pattern>org.checkerframework</pattern>
<shadedPattern>net.draycia.simplechat.libs.checkerframework</shadedPattern>
</relocation>
</relocations>
</configuration>
<executions>
<execution>
@@ -110,6 +68,13 @@
</resources>
</build>
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
@@ -120,9 +85,14 @@
<dependency>
<groupId>net.draycia</groupId>
<artifactId>SimpleChat</artifactId>
<version>1.0-SNAPSHOT</version>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.MilkBowl</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.7</version>
<scope>provided</scope>
<classifier>shaded</classifier>
</dependency>
</dependencies>
@@ -5,7 +5,6 @@ import co.aikar.commands.CommandIssuer;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Default;
import net.draycia.simplechat.SimpleChat;
import net.draycia.simplechatmoderation.SimpleChatModeration;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component;
@@ -5,11 +5,11 @@ import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandCompletion;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Default;
import net.draycia.simplechat.SimpleChat;
import net.draycia.simplechat.storage.ChatUser;
import net.draycia.simplechatmoderation.SimpleChatModeration;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.command.CommandSender;
@CommandAlias("mute")
@@ -28,11 +28,17 @@ public class MuteCommand extends BaseCommand {
String format;
if (targetUser.isMuted()) {
targetUser.setMuted(true);
targetUser.setMuted(false);
format = moderation.getConfig().getString("language.no-longer-muted");
} else {
targetUser.setMuted(false);
format = moderation.getConfig().getString("language.is-now-muted");
Permission permission = moderation.getSimpleChat().getPermission();
if (permission.playerHas(null, targetUser.asOfflinePlayer(), "simplechat.mute.exempt")) {
format = moderation.getConfig().getString("language.mute-exempt");
} else {
targetUser.setMuted(true);
format = moderation.getConfig().getString("language.is-now-muted");
}
}
Component message = MiniMessage.get().parse(format, "br", "\n",
@@ -9,6 +9,7 @@ import net.draycia.simplechat.storage.ChatUser;
import net.draycia.simplechatmoderation.SimpleChatModeration;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.command.CommandSender;
@CommandAlias("shadowmute|sm|smute")
@@ -30,8 +31,14 @@ public class ShadowMuteCommand extends BaseCommand {
targetUser.setShadowMuted(false);
format = moderation.getConfig().getString("language.no-longer-shadow-muted");
} else {
targetUser.setShadowMuted(true);
format = moderation.getConfig().getString("language.is-now-shadow-muted");
Permission permission = moderation.getSimpleChat().getPermission();
if (permission.playerHas(null, targetUser.asOfflinePlayer(), "simplechat.shadowmute.exempt")) {
format = moderation.getConfig().getString("language.shadow-mute-exempt");
} else {
targetUser.setShadowMuted(true);
format = moderation.getConfig().getString("language.is-now-shadow-muted");
}
}
Component message = MiniMessage.get().parse(format, "br", "\n",
@@ -0,0 +1,16 @@
package net.draycia.simplechatmoderation.listeners;
import net.draycia.simplechat.events.ChatFormatEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
public class MuteHandler implements Listener {
@EventHandler
public void onMute(ChatFormatEvent event) {
if (event.getUser().isMuted()) {
event.setCancelled(true);
}
}
}
@@ -0,0 +1,26 @@
package net.draycia.simplechatmoderation.listeners;
import net.draycia.simplechat.events.ChatComponentEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
public class ShadowMuteHandler implements Listener {
@EventHandler(priority = EventPriority.LOWEST)
public void onComponent(ChatComponentEvent event) {
if (event.getUser().isShadowMuted()) {
if (event.getRecipients().size() == 1 && event.getUser().equals(event.getRecipients().get(0))) {
return;
}
try {
event.getRecipients().clear();
event.getRecipients().add(event.getUser());
} catch (UnsupportedOperationException e) {}
}
// TODO: figure out a way to add the console "[SM]" prefix for shadow muted players
}
}
@@ -22,8 +22,10 @@ clear-chat:
language:
is-now-shadow-muted: '<yellow>User <user> is now shadow muted!'
no-longer-shadow-muted: '<yellow>User <user> is no longer shadow muted!'
shadow-mute-exempt: '<red>User <user> is exempt from being shadow muted!'
is-now-muted: '<yellow>User <user> is now muted!'
no-longer-muted: '<yellow>User <user> is no longer muted!'
mute-exempt: '<red>User <user> is exempt from being muted!'
reloaded: '<yellow>ChatModeration config has been reloaded!'
clear-notify: '<yellow>Chat has been cleared by <player>.'
clear-exempt: '<yellow>You were exempt from the clear due to your permissions!'