GriefPrevention integration

This commit is contained in:
Vankka 2023-05-18 12:46:03 +03:00
parent 1fa290402a
commit a25e1a2449
No known key found for this signature in database
GPG Key ID: 6E50CB7A29B96AD0
5 changed files with 56 additions and 1 deletions

View File

@ -70,6 +70,7 @@ dependencies {
// Chat Integrations
compileOnly(libs.chatty)
compileOnly(libs.griefprevention)
compileOnly(libs.lunachat)
compileOnly(libs.mcmmo)
compileOnly(libs.townychat)

View File

@ -248,6 +248,7 @@ public class BukkitDiscordSRV extends ServerDiscordSRV<DiscordSRVBukkitBootstrap
// Chat Integrations
registerIntegration("com.discordsrv.bukkit.integration.chat.ChattyChatIntegration");
registerIntegration("com.discordsrv.bukkit.integration.chat.GriefPreventionChatIntegration");
registerIntegration("com.discordsrv.bukkit.integration.chat.LunaChatIntegration");
registerIntegration("com.discordsrv.bukkit.integration.chat.McMMOChatIntegration");
registerIntegration("com.discordsrv.bukkit.integration.chat.TownyChatIntegration");

View File

@ -0,0 +1,48 @@
package com.discordsrv.bukkit.integration.chat;
import com.discordsrv.api.event.bus.EventPriority;
import com.discordsrv.api.event.bus.Subscribe;
import com.discordsrv.api.event.events.message.receive.game.GameChatMessageReceiveEvent;
import com.discordsrv.api.player.DiscordSRVPlayer;
import com.discordsrv.bukkit.BukkitDiscordSRV;
import com.discordsrv.common.logging.NamedLogger;
import com.discordsrv.common.module.type.PluginIntegration;
import me.ryanhamshire.GriefPrevention.GriefPrevention;
import org.jetbrains.annotations.NotNull;
public class GriefPreventionChatIntegration extends PluginIntegration<BukkitDiscordSRV> {
public GriefPreventionChatIntegration(BukkitDiscordSRV discordSRV) {
super(discordSRV, new NamedLogger(discordSRV, "GRIEFPREVENTION"));
}
@Override
public @NotNull String getIntegrationName() {
return "GriefPrevention";
}
@Override
public boolean isEnabled() {
try {
Class.forName("me.ryanhamshire.GriefPrevention.GriefPrevention");
} catch (ClassNotFoundException ignored) {
return false;
}
return super.isEnabled();
}
@Subscribe(priority = EventPriority.EARLY)
public void onGameChatMessageReceive(GameChatMessageReceiveEvent event) {
GriefPrevention griefPrevention = (GriefPrevention) discordSRV.server().getPluginManager().getPlugin(getIntegrationName());
if (griefPrevention == null) {
return;
}
DiscordSRVPlayer player = event.getPlayer();
if (griefPrevention.dataStore.isSoftMuted(player.uniqueId())) {
logger().debug(player.username() + " is softmuted");
event.setCancelled(true);
}
}
}

View File

@ -64,7 +64,11 @@ public class McMMOChatIntegration extends PluginIntegration<BukkitDiscordSRV> im
return;
}
if (ChatAPI.isUsingPartyChat(player) || ChatAPI.isUsingAdminChat(player)) {
if (ChatAPI.isUsingPartyChat(player)) {
logger().debug(player.getName() + " is using party chat");
event.setCancelled(true);
} else if (ChatAPI.isUsingAdminChat(player)) {
logger().debug(player.getName() + " is using admin chat");
event.setCancelled(true);
}
}

View File

@ -110,6 +110,7 @@ dependencyResolutionManagement {
library('chatty', 'ru.mrbrikster', 'chatty-api').version('2.19.13')
library('lunachat', 'com.github.ucchyocean.lc', 'LunaChat').version('3.0.16')
library('mcmmo', 'com.gmail.nossr50', 'mcmmo').version('2.1.220')
library('griefprevention', 'me.ryanhamshire', 'GriefPrevention').version('16.18.1')
// Logging
library('slf4j-api', 'org.slf4j', 'slf4j-api').version('1.7.36')