update to built-in modules style

This commit is contained in:
Larry committed 2020-08-22 13:17:28 -06:00
commit 9d3e893ca9
85 files changed
+455 -702

No files matched your search

-71
View File
@@ -1,71 +0,0 @@
plugins {
id 'com.github.johnrengelman.shadow' version '6.0.0'
id 'net.minecrell.plugin-yml.bukkit' version '0.3.0'
}
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
compile 'co.aikar:acf-bukkit:0.5.0-SNAPSHOT'
compile 'net.kyori:adventure-api:4.0.0-SNAPSHOT'
compile 'net.kyori:adventure-nbt:4.0.0-SNAPSHOT'
compile 'net.kyori:adventure-platform-bukkit:4.0.0-SNAPSHOT'
compile 'net.kyori:adventure-text-minimessage:3.0.0-SNAPSHOT'
compile 'de.themoep:minedown-adventure:1.6.1-SNAPSHOT'
compile 'co.aikar:idb-bukkit:1.0.0-SNAPSHOT'
compile 'com.zaxxer:HikariCP:2.4.1'
compile 'io.github.leonardosnt:bungeechannelapi:1.0.0-SNAPSHOT'
compile 'io.lettuce:lettuce-core:6.0.0.M1'
compileOnly 'me.clip:placeholderapi:2.10.9'
compileOnly 'com.github.TownyAdvanced:Towny:0.96.1.11'
compileOnly 'com.github.MilkBowl:VaultAPI:1.7'
compileOnly 'com.vexsoftware:nuvotifier-universal:2.6.0'
compileOnly 'net.luckperms:api:5.1'
compileOnly 'org.jetbrains:annotations:16.0.1'
}
description = 'CarbonChat'
bukkit {
name = description
version = project.version
main = 'net.draycia.carbon.CarbonChat'
apiVersion = '1.13'
author = 'Draycia'
depend = ['PlaceholderAPI', 'Vault']
softDepend = ['LuckPerms']
loadBefore = ["Essentials"]
permissions {
'carbonchat.channels.Global.see' {
setDefault("TRUE")
}
'carbonchat.channels.Global.use' {
setDefault("TRUE")
}
}
}
tasks.build.dependsOn tasks.shadowJar
shadowJar {
minimize()
archiveFileName.set(project.name + "-" + project.property('projectVersion') + ".jar")
}
jar {
archiveFileName.set(project.name + "-" + project.property('projectVersion') + ".jar")
}
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
task relocateShadowJar(type: ConfigureShadowRelocation) {
target = tasks.shadowJar
prefix = "net.draycia.carbon.libs" // Default value is "shadow"
}
tasks.shadowJar.dependsOn tasks.relocateShadowJar
-35
View File
@@ -1,35 +0,0 @@
plugins {
id 'com.github.johnrengelman.shadow' version '6.0.0'
id 'net.minecrell.plugin-yml.bukkit' version '0.3.0'
}
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
compileOnly 'com.github.mcMMO-Dev:mcMMO:-SNAPSHOT'
compileOnly project(path: ':CarbonChat', configuration: 'shadow')
}
description = 'CarbonChatMCMMO'
bukkit {
name = description
version = project.version
main = 'net.draycia.carbonmcmmo.CarbonChatMCMMO'
apiVersion = '1.13'
author = 'Draycia'
depend = ['CarbonChat', 'mcMMO']
}
tasks.build.dependsOn tasks.shadowJar
shadowJar {
archiveFileName.set(project.name + "-" + project.property('projectVersion') + ".jar")
}
jar {
archiveFileName.set(project.name + "-" + project.property('projectVersion') + ".jar")
}
@@ -1 +0,0 @@
cancellation-message: "<red>You do not have a party!"
-35
View File
@@ -1,35 +0,0 @@
plugins {
id 'com.github.johnrengelman.shadow' version '6.0.0'
id 'net.minecrell.plugin-yml.bukkit' version '0.3.0'
}
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
compileOnly project(path: ':CarbonChat', configuration: 'shadow')
}
description = 'CarbonChatModeration'
bukkit {
name = description
version = project.version
main = 'net.draycia.carbonmoderation.CarbonChatModeration'
apiVersion = '1.13'
author = 'Draycia'
depend = ['CarbonChat']
}
tasks.build.dependsOn tasks.shadowJar
shadowJar {
relocate "co.aikar.commands", "net.draycia.carbon.libs.co.aikar.commands"
archiveFileName.set(project.name + "-" + project.property('projectVersion') + ".jar")
}
jar {
archiveFileName.set(project.name + "-" + project.property('projectVersion') + ".jar")
}
@@ -1,54 +0,0 @@
package net.draycia.carbonmoderation;
import net.draycia.carbon.libs.co.aikar.commands.BukkitCommandManager;
import net.draycia.carbon.CarbonChat;
import net.draycia.carbonmoderation.commands.ClearChatCommand;
import net.draycia.carbonmoderation.commands.ModReloadCommand;
import net.draycia.carbonmoderation.commands.MuteCommand;
import net.draycia.carbonmoderation.commands.ShadowMuteCommand;
import net.draycia.carbonmoderation.listeners.CapsHandler;
import net.draycia.carbonmoderation.listeners.FilterHandler;
import net.draycia.carbonmoderation.listeners.MuteHandler;
import net.draycia.carbonmoderation.listeners.ShadowMuteHandler;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
public final class CarbonChatModeration extends JavaPlugin {
private CarbonChat carbonChat;
@Override
public void onEnable() {
saveDefaultConfig();
carbonChat = (CarbonChat)Bukkit.getPluginManager().getPlugin("CarbonChat");
registerCommands();
registerListeners();
}
private void registerCommands() {
BukkitCommandManager commandManager = carbonChat.getCommandManager().getCommandManager();
commandManager.registerCommand(new ClearChatCommand(this));
commandManager.registerCommand(new MuteCommand(this));
commandManager.registerCommand(new ShadowMuteCommand(this));
commandManager.registerCommand(new ModReloadCommand(this));
}
private void registerListeners() {
Bukkit.getPluginManager().registerEvents(new CapsHandler(this), this);
Bukkit.getPluginManager().registerEvents(new FilterHandler(this), this);
Bukkit.getPluginManager().registerEvents(new MuteHandler(), this);
Bukkit.getPluginManager().registerEvents(new ShadowMuteHandler(this), this);
}
@Override
public void onDisable() {
}
public CarbonChat getCarbonChat() {
return carbonChat;
}
}
@@ -1,52 +0,0 @@
package net.draycia.carbonmoderation.commands;
import net.draycia.carbon.libs.co.aikar.commands.BaseCommand;
import net.draycia.carbon.libs.co.aikar.commands.annotation.CommandAlias;
import net.draycia.carbon.libs.co.aikar.commands.annotation.CommandPermission;
import net.draycia.carbon.libs.co.aikar.commands.annotation.Default;
import net.draycia.carbon.storage.ChatUser;
import net.draycia.carbonmoderation.CarbonChatModeration;
import net.draycia.carbon.libs.net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandAlias("clearchat|cc")
@CommandPermission("carbonchat.clearchat.clear")
public class ClearChatCommand extends BaseCommand {
private final CarbonChatModeration moderation;
public ClearChatCommand(CarbonChatModeration moderation) {
this.moderation = moderation;
}
@Default
public void baseCommand(CommandSender issuer) {
String format = moderation.getConfig().getString("clear-chat.message", "");
Component component = moderation.getCarbonChat().getAdventureManager().processMessage(format, "br", "\n");
for (Player player : Bukkit.getOnlinePlayers()) {
if (player.hasPermission("carbonchat.clearchat.exempt")) {
continue;
}
ChatUser audience = moderation.getCarbonChat().getUserService().wrap(player);
for (int i = 0; i < moderation.getConfig().getInt("clear-chat.message-count", 100); i++) {
audience.sendMessage(component);
}
if (player.hasPermission("carbonchat.clearchat.notify")) {
String message = moderation.getConfig().getString("language.clear-notify");
audience.sendMessage(moderation.getCarbonChat().getAdventureManager().processMessage(message, "player", issuer.getName()));
}
if (player.hasPermission("carbonchat.clearchat.exempt")) {
String message = moderation.getConfig().getString("language.clear-exempt");
audience.sendMessage(moderation.getCarbonChat().getAdventureManager().processMessage(message, "player", issuer.getName()));
}
}
}
}
@@ -1,33 +0,0 @@
package net.draycia.carbonmoderation.commands;
import net.draycia.carbon.libs.co.aikar.commands.BaseCommand;
import net.draycia.carbon.libs.co.aikar.commands.annotation.CommandAlias;
import net.draycia.carbon.libs.co.aikar.commands.annotation.CommandPermission;
import net.draycia.carbon.libs.co.aikar.commands.annotation.Default;
import net.draycia.carbon.libs.co.aikar.commands.annotation.Dependency;
import net.draycia.carbon.libs.net.kyori.adventure.text.Component;
import net.draycia.carbonmoderation.CarbonChatModeration;
import org.bukkit.command.CommandSender;
@CommandAlias("modreload|mreload")
@CommandPermission("carbonchat.reload")
public class ModReloadCommand extends BaseCommand {
private final CarbonChatModeration moderation;
public ModReloadCommand(CarbonChatModeration moderation) {
this.moderation = moderation;
}
@Default
public void baseCommand(CommandSender sender) {
moderation.reloadConfig();
Component message = moderation.getCarbonChat().getAdventureManager()
.processMessage(moderation.getConfig().getString("language.reloaded"),
"br", "\n");
moderation.getCarbonChat().getAdventureManager().getAudiences().audience(sender).sendMessage(message);
}
}
@@ -1,61 +0,0 @@
package net.draycia.carbonmoderation.commands;
import net.draycia.carbon.libs.co.aikar.commands.annotation.Syntax;
import net.draycia.carbon.libs.co.aikar.commands.BaseCommand;
import net.draycia.carbon.libs.co.aikar.commands.annotation.CommandAlias;
import net.draycia.carbon.libs.co.aikar.commands.annotation.CommandCompletion;
import net.draycia.carbon.libs.co.aikar.commands.annotation.CommandPermission;
import net.draycia.carbon.libs.co.aikar.commands.annotation.Default;
import net.draycia.carbon.storage.ChatUser;
import net.draycia.carbonmoderation.CarbonChatModeration;
import net.draycia.carbon.libs.net.kyori.adventure.audience.Audience;
import net.draycia.carbon.libs.net.kyori.adventure.text.Component;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
@CommandAlias("mute")
@CommandPermission("carbonchat.mute")
public class MuteCommand extends BaseCommand {
private final CarbonChatModeration moderation;
public MuteCommand(CarbonChatModeration moderation) {
this.moderation = moderation;
}
@Default
@CommandCompletion("@players")
@Syntax("<player>")
public void baseCommand(CommandSender sender, ChatUser targetUser) {
Audience audience = moderation.getCarbonChat().getAdventureManager().getAudiences().audience(sender);
if (targetUser.isMuted()) {
targetUser.setMuted(false);
String format = moderation.getConfig().getString("language.no-longer-muted");
Component message = moderation.getCarbonChat().getAdventureManager().processMessage(format, "br", "\n",
"player", targetUser.asOfflinePlayer().getName());
audience.sendMessage(message);
} else {
Bukkit.getScheduler().runTaskAsynchronously(moderation, () -> {
Permission permission = moderation.getCarbonChat().getPermission();
String format;
if (permission.playerHas(null, targetUser.asOfflinePlayer(), "carbonchat.mute.exempt")) {
format = moderation.getConfig().getString("language.mute-exempt");
} else {
targetUser.setMuted(true);
format = moderation.getConfig().getString("language.is-now-muted");
}
Component message = moderation.getCarbonChat().getAdventureManager().processMessage(format, "br", "\n",
"player", targetUser.asOfflinePlayer().getName());
audience.sendMessage(message);
});
}
}
}
@@ -1,60 +0,0 @@
package net.draycia.carbonmoderation.commands;
import net.draycia.carbon.libs.co.aikar.commands.annotation.Syntax;
import net.draycia.carbon.libs.co.aikar.commands.BaseCommand;
import net.draycia.carbon.libs.co.aikar.commands.annotation.CommandAlias;
import net.draycia.carbon.libs.co.aikar.commands.annotation.CommandCompletion;
import net.draycia.carbon.libs.co.aikar.commands.annotation.CommandPermission;
import net.draycia.carbon.libs.co.aikar.commands.annotation.Default;
import net.draycia.carbon.storage.ChatUser;
import net.draycia.carbonmoderation.CarbonChatModeration;
import net.draycia.carbon.libs.net.kyori.adventure.audience.Audience;
import net.draycia.carbon.libs.net.kyori.adventure.text.Component;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
@CommandAlias("shadowmute|sm|smute")
@CommandPermission("carbonchat.shadowmute")
public class ShadowMuteCommand extends BaseCommand {
private final CarbonChatModeration moderation;
public ShadowMuteCommand(CarbonChatModeration moderation) {
this.moderation = moderation;
}
@Default
@CommandCompletion("@players")
@Syntax("<player>")
public void baseCommand(CommandSender sender, ChatUser targetUser) {
Audience audience = moderation.getCarbonChat().getAdventureManager().getAudiences().audience(sender);
if (targetUser.isShadowMuted()) {
targetUser.setShadowMuted(false);
String format = moderation.getConfig().getString("language.no-longer-shadow-muted");
Component message = moderation.getCarbonChat().getAdventureManager().processMessage(format, "br", "\n",
"player", targetUser.asOfflinePlayer().getName());
audience.sendMessage(message);
} else {
Bukkit.getScheduler().runTaskAsynchronously(moderation, () -> {
Permission permission = moderation.getCarbonChat().getPermission();
String format;
if (permission.playerHas(null, targetUser.asOfflinePlayer(), "carbonchat.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 = moderation.getCarbonChat().getAdventureManager().processMessage(format, "br", "\n",
"player", targetUser.asOfflinePlayer().getName());
audience.sendMessage(message);
});
}
}
}
-37
View File
@@ -1,37 +0,0 @@
plugins {
id 'com.github.johnrengelman.shadow' version '6.0.0'
id 'net.minecrell.plugin-yml.bukkit' version '0.3.0'
}
repositories {
mavenLocal()
mavenCentral()
maven { url = "https://jitpack.io" }
}
dependencies {
compileOnly 'com.github.TownyAdvanced:Towny:0.96.2.0'
compileOnly project(':CarbonChat')
}
description = 'CarbonChatTowny'
bukkit {
name = description
version = project.version
main = 'net.draycia.carbontowny.CarbonChatTowny'
apiVersion = '1.13'
author = 'Draycia'
depend = ['CarbonChat', 'Towny']
}
tasks.build.dependsOn tasks.shadowJar
shadowJar {
archiveFileName.set(project.name + "-" + project.property('projectVersion') + ".jar")
}
jar {
archiveFileName.set(project.name + "-" + project.property('projectVersion') + ".jar")
}
@@ -1 +0,0 @@
cancellation-message: "<red>You do not belong to a town!"
-37
View File
@@ -1,37 +0,0 @@
plugins {
id 'com.github.johnrengelman.shadow' version '6.0.0'
id 'net.minecrell.plugin-yml.bukkit' version '0.3.0'
}
repositories {
mavenLocal()
mavenCentral()
maven { url = "https://maven.enginehub.org/repo/" }
}
dependencies {
compileOnly 'com.sk89q.worldguard:worldguard-bukkit:7.0.4-SNAPSHOT'
compileOnly project(':CarbonChat')
}
description = 'CarbonChatWorldGuard'
bukkit {
name = description
version = project.version
main = 'net.draycia.carbonworldguard.CarbonChatWorldGuard'
apiVersion = '1.13'
author = 'Draycia'
depend = ['CarbonChat', 'WorldGuard']
}
tasks.build.dependsOn tasks.shadowJar
shadowJar {
archiveFileName.set(project.name + "-" + project.property('projectVersion') + ".jar")
}
jar {
archiveFileName.set(project.name + "-" + project.property('projectVersion') + ".jar")
}
Whitespace-only changes.
+92 -55
View File
@@ -1,73 +1,110 @@
plugins {
id 'com.github.johnrengelman.shadow' version '6.0.0'
id 'net.minecrell.plugin-yml.bukkit' version '0.3.0'
id 'com.palantir.git-version' version '0.12.3'
}
apply plugin: 'java-library'
apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: 'maven'
ext.projectVersion = '1.0'
def gitHash = versionDetails().gitHash
allprojects {
group = 'net.draycia'
version = project.property('projectVersion') + '-' + gitHash
group = 'net.draycia'
description = 'CarbonChat'
version = project.property('projectVersion') + '-' + gitHash
repositories {
mavenLocal()
mavenCentral()
maven {url = "https://maven.enginehub.org/repo/"}
maven {url = 'https://repo.maven.apache.org/maven2'}
maven {url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'}
maven {url = 'https://oss.sonatype.org/content/groups/public/'}
maven {url = 'https://repo.extendedclip.com/content/repositories/placeholderapi/'}
maven {url = 'https://jitpack.io'}
maven {url = 'https://dl.bintray.com/ichbinjoe/public/'}
maven {url = 'https://repo.codemc.org/repository/maven-public/'}
maven {url = 'https://repo.minebench.de/'}
maven {url = "https://repo.aikar.co/content/groups/aikar/"}
}
apply plugin: 'base'
dependencies {
compile 'co.aikar:acf-bukkit:0.5.0-SNAPSHOT'
compile 'net.kyori:adventure-api:4.0.0-SNAPSHOT'
compile 'net.kyori:adventure-nbt:4.0.0-SNAPSHOT'
compile 'net.kyori:adventure-platform-bukkit:4.0.0-SNAPSHOT'
compile 'net.kyori:adventure-text-minimessage:3.0.0-SNAPSHOT'
compile 'de.themoep:minedown-adventure:1.6.1-SNAPSHOT'
compile 'co.aikar:idb-bukkit:1.0.0-SNAPSHOT'
compile 'com.zaxxer:HikariCP:2.4.1'
compile 'io.github.leonardosnt:bungeechannelapi:1.0.0-SNAPSHOT'
compile 'io.lettuce:lettuce-core:6.0.0.M1'
subprojects {
apply plugin: 'java-library'
apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: 'maven'
compileOnly 'com.gmail.nossr50.mcMMO:mcMMO:2.1.143'
compileOnly 'com.github.TownyAdvanced:Towny:0.96.2.0'
compileOnly 'com.sk89q.worldguard:worldguard-bukkit:7.0.4-SNAPSHOT'
compileOnly 'me.clip:placeholderapi:2.10.9'
compileOnly 'com.github.TownyAdvanced:Towny:0.96.1.11'
compileOnly 'com.github.MilkBowl:VaultAPI:1.7'
compileOnly 'com.vexsoftware:nuvotifier-universal:2.6.0'
compileOnly 'net.luckperms:api:5.1'
compileOnly 'org.jetbrains:annotations:16.0.1'
}
repositories {
mavenLocal()
mavenCentral()
bukkit {
name = project.description
version = project.version
main = 'net.draycia.carbon.CarbonChat'
apiVersion = '1.13'
author = 'Draycia'
depend = ['PlaceholderAPI', 'Vault']
softDepend = ['LuckPerms', 'Towny', 'mcMMO', 'WorldGuard']
loadBefore = ["Essentials"]
permissions {
'carbonchat.channels.global.see' {
setDefault("TRUE")
}
maven {url = 'https://repo.maven.apache.org/maven2'}
maven {url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'}
maven {url = 'https://oss.sonatype.org/content/groups/public/'}
maven {url = 'https://repo.extendedclip.com/content/repositories/placeholderapi/'}
maven {url = 'https://jitpack.io'}
maven {url = 'https://dl.bintray.com/ichbinjoe/public/'}
maven {url = 'https://repo.codemc.org/repository/maven-public/'}
maven {url = 'https://repo.minebench.de/'}
maven {url = "https://repo.aikar.co/content/groups/aikar/"}
}
dependencies {
compileOnly 'org.spigotmc:spigot-api:1.16.1-R0.1-SNAPSHOT'
compileOnly 'com.github.MilkBowl:VaultAPI:1.7'
compileOnly 'co.aikar:acf-bukkit:0.5.0-SNAPSHOT'
compileOnly 'net.kyori:adventure-api:4.0.0-SNAPSHOT'
compileOnly 'net.kyori:adventure-nbt:4.0.0-SNAPSHOT'
compileOnly 'net.kyori:adventure-platform-bukkit:4.0.0-SNAPSHOT'
compileOnly 'net.kyori:adventure-text-minimessage:3.0.0-SNAPSHOT'
compileOnly 'de.themoep:minedown-adventure:1.6.1-SNAPSHOT'
compileOnly 'co.aikar:idb-bukkit:1.0.0-SNAPSHOT'
compileOnly 'com.zaxxer:HikariCP:2.4.1'
compileOnly 'io.github.leonardosnt:bungeechannelapi:1.0.0-SNAPSHOT'
compileOnly 'io.lettuce:lettuce-core:6.0.0.M1'
}
sourceCompatibility = '1.8'
publishing {
publications {
maven(MavenPublication) {
from(components.java)
}
'carbonchat.channels.global.use' {
setDefault("TRUE")
}
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
tasks.withType(Jar) {
getDestinationDirectory().set(file("$rootDir/build/bundled"))
}
}
sourceCompatibility = '1.8'
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
tasks.withType(Jar) {
getDestinationDirectory().set(file("$rootDir/build"))
}
tasks.build.dependsOn tasks.shadowJar
shadowJar {
minimize()
archiveFileName.set(project.description + "-" + project.property('projectVersion') + ".jar")
}
jar {
archiveFileName.set(project.description + "-" + project.property('projectVersion') + ".jar")
}
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
task relocateShadowJar(type: ConfigureShadowRelocation) {
target = tasks.shadowJar
prefix = "net.draycia.carbon.libs" // Default value is "shadow"
}
tasks.shadowJar.dependsOn tasks.relocateShadowJar
clean.doFirst {
delete "$rootDir/build/bundled"
}
}
-11
View File
@@ -1,11 +0,0 @@
/*
* This file was generated by the Gradle 'init' task.
*/
rootProject.name = 'CarbonChatPlugin'
include(':CarbonChat')
include(':CarbonChatModeration')
include(':CarbonChatMCMMO')
include(':CarbonChatTowny')
include(':CarbonChatWorldGuard')
@@ -1,6 +1,10 @@
package net.draycia.carbon;
import net.draycia.carbon.channels.contexts.impl.EconomyContext;
import net.draycia.carbon.channels.contexts.impl.DistanceContext;
import net.draycia.carbon.channels.contexts.impl.TownyContext;
import net.draycia.carbon.channels.contexts.impl.WorldGuardContext;
import net.draycia.carbon.channels.contexts.impl.mcMMOContext;
import net.draycia.carbon.listeners.*;
import net.draycia.carbon.managers.*;
import net.draycia.carbon.messaging.MessageManager;
@@ -10,10 +14,17 @@ import net.draycia.carbon.storage.impl.MySQLUserService;
import net.draycia.carbon.util.CarbonPlaceholders;
import net.draycia.carbon.util.ItemStackUtils;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.Bukkit;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.io.IOException;
public final class CarbonChat extends JavaPlugin {
private Permission permission;
@@ -28,11 +39,43 @@ public final class CarbonChat extends JavaPlugin {
private ItemStackUtils itemStackUtils;
private YamlConfiguration modConfig;
private YamlConfiguration languageConfig;
public static final LegacyComponentSerializer LEGACY =
LegacyComponentSerializer.builder().extractUrls().character('§').build();
@Override
public void onEnable() {
// Ensure config is present to be modified by the user
if (!(new File(getDataFolder(), "config.yml").exists())) {
saveDefaultConfig();
}
if (!(new File(getDataFolder(), "moderation.yml").exists())) {
saveResource("moderation.yml", false);
}
if (!(new File(getDataFolder(), "language.yml").exists())) {
saveResource("language.yml", false);
}
modConfig = new YamlConfiguration();
try {
modConfig.load(new File(getDataFolder(), "moderation.yml"));
} catch (IOException | InvalidConfigurationException e) {
e.printStackTrace();
}
languageConfig = new YamlConfiguration();
try {
languageConfig.load(new File(getDataFolder(), "language.yml"));
} catch (IOException | InvalidConfigurationException e) {
e.printStackTrace();
}
// Setup Adventure
adventureManager = new AdventureManager(this);
@@ -45,9 +88,6 @@ public final class CarbonChat extends JavaPlugin {
// Setup vault and permissions
permission = getServer().getServicesManager().getRegistration(Permission.class).getProvider();
// Ensure config is present to be modified by the user
saveDefaultConfig();
// Initialize managers
commandManager = new CommandManager(this);
channelManager = new ChannelManager(this);
@@ -72,6 +112,22 @@ public final class CarbonChat extends JavaPlugin {
registerContexts();
new CarbonPlaceholders(this).register();
if (Bukkit.getPluginManager().isPluginEnabled("Towny")) {
getServer().getPluginManager().registerEvents(new TownyContext(this), this);
}
if (Bukkit.getPluginManager().isPluginEnabled("mcMMO")) {
getServer().getPluginManager().registerEvents(new mcMMOContext(this), this);
}
if (Bukkit.getPluginManager().isPluginEnabled("WorldGuard")) {
getServer().getPluginManager().registerEvents(new WorldGuardContext(this), this);
}
if (Bukkit.getServicesManager().isProvidedFor(Economy.class)) {
Bukkit.getPluginManager().registerEvents(new EconomyContext(this), this);
}
}
@Override
@@ -94,13 +150,25 @@ public final class CarbonChat extends JavaPlugin {
pluginManager.registerEvents(new RelationalPlaceholderHandler(), this);
pluginManager.registerEvents(new UserFormattingListener(), this);
pluginManager.registerEvents(new WhisperPingHandler(this), this);
pluginManager.registerEvents(new RequiredBalanceHandler(this), this);
pluginManager.registerEvents(new CapsHandler(this), this);
pluginManager.registerEvents(new FilterHandler(this), this);
pluginManager.registerEvents(new MuteHandler(), this);
pluginManager.registerEvents(new ShadowMuteHandler(this), this);
}
private void registerContexts() {
getContextManager().register("distance", new DistanceContext());
}
public YamlConfiguration getModConfig() {
return modConfig;
}
public YamlConfiguration getLanguage() {
return languageConfig;
}
public Permission getPermission() {
return permission;
}
@@ -1,4 +1,4 @@
package net.draycia.carbon.listeners;
package net.draycia.carbon.channels.contexts.impl;
import net.draycia.carbon.CarbonChat;
import net.draycia.carbon.events.PreChatFormatEvent;
@@ -8,35 +8,17 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.plugin.RegisteredServiceProvider;
public class RequiredBalanceHandler implements Listener {
public class EconomyContext implements Listener {
private final CarbonChat carbonChat;
private final Economy economy;
private final boolean enabled;
public RequiredBalanceHandler(CarbonChat carbonChat) {
public EconomyContext(CarbonChat carbonChat) {
this.carbonChat = carbonChat;
RegisteredServiceProvider<Economy> registeredEco = carbonChat.getServer().getServicesManager().getRegistration(Economy.class);
if (registeredEco == null) {
carbonChat.getServer().getLogger().warning("No Vault-compatible Economy plugin detected! Economy features won't work!");
this.economy = null;
this.enabled = false;
return;
}
this.enabled = true;
this.economy = registeredEco.getProvider();
this.economy = carbonChat.getServer().getServicesManager().getRegistration(Economy.class).getProvider();
}
@EventHandler
public void onChatReqBal(PreChatFormatEvent event) {
if (!enabled) {
return;
}
Object requiredBalObject = event.getChannel().getContext("vault-balance");
Double requiredBal;
@@ -66,10 +48,6 @@ public class RequiredBalanceHandler implements Listener {
@EventHandler
public void onChatCost(PreChatFormatEvent event) {
if (!enabled) {
return;
}
Object costObject = event.getChannel().getContext("vault-cost");
Double cost;
@@ -1,4 +1,4 @@
package net.draycia.carbontowny;
package net.draycia.carbon.channels.contexts.impl;
import com.palmergames.bukkit.towny.TownyAPI;
import com.palmergames.bukkit.towny.event.TownRemoveResidentEvent;
@@ -8,32 +8,25 @@ import net.draycia.carbon.CarbonChat;
import net.draycia.carbon.events.ChannelSwitchEvent;
import net.draycia.carbon.events.PreChatFormatEvent;
import net.draycia.carbon.storage.ChatUser;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
public final class CarbonChatTowny extends JavaPlugin implements Listener {
public final class TownyContext implements Listener {
private CarbonChat carbonChat;
private final CarbonChat carbonChat;
private static final String KEY = "towny-town";
@Override
public void onEnable() {
saveDefaultConfig();
public TownyContext(CarbonChat carbonChat) {
this.carbonChat = carbonChat;
carbonChat = (CarbonChat) Bukkit.getPluginManager().getPlugin("CarbonChat");
carbonChat.getContextManager().register("towny-town", (context) -> {
this.carbonChat.getContextManager().register("towny-town", (context) -> {
if ((context.getValue() instanceof Boolean) && ((Boolean) context.getValue())) {
return isInSameTown(context.getSender(), context.getTarget());
}
return true;
});
Bukkit.getPluginManager().registerEvents(this, this);
}
@EventHandler(ignoreCancelled = true)
@@ -43,7 +36,7 @@ public final class CarbonChatTowny extends JavaPlugin implements Listener {
if ((town instanceof Boolean) && ((Boolean) town)) {
if (!isInTown(event.getUser())) {
event.setCancelled(true);
event.setFailureMessage(getConfig().getString("cancellation-message"));
event.setFailureMessage(carbonChat.getConfig().getString("contexts.Towny.cancellation-message"));
}
}
}
@@ -1,4 +1,4 @@
package net.draycia.carbonworldguard;
package net.draycia.carbon.channels.contexts.impl;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.util.Location;
@@ -12,27 +12,19 @@ import net.draycia.carbon.CarbonChat;
import net.draycia.carbon.events.ChannelSwitchEvent;
import net.draycia.carbon.events.PreChatFormatEvent;
import net.draycia.carbon.storage.ChatUser;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.List;
public final class CarbonChatWorldGuard extends JavaPlugin implements Listener {
public final class WorldGuardContext implements Listener {
private static final String KEY = "worldguard-region";
@Override
public void onEnable() {
saveDefaultConfig();
CarbonChat carbonChat = (CarbonChat) Bukkit.getPluginManager().getPlugin("CarbonChat");
public WorldGuardContext(CarbonChat carbonChat) {
carbonChat.getContextManager().register(KEY, (context) -> {
return this.testContext(context.getSender(), context.getTarget(), context.getValue());
});
Bukkit.getPluginManager().registerEvents(this, this);
}
@EventHandler(ignoreCancelled = true)
@@ -1,4 +1,4 @@
package net.draycia.carbonmcmmo;
package net.draycia.carbon.channels.contexts.impl;
import com.gmail.nossr50.api.PartyAPI;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent;
@@ -6,31 +6,24 @@ import net.draycia.carbon.CarbonChat;
import net.draycia.carbon.events.ChannelSwitchEvent;
import net.draycia.carbon.events.PreChatFormatEvent;
import net.draycia.carbon.storage.ChatUser;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
public final class CarbonChatMCMMO extends JavaPlugin implements Listener {
public final class mcMMOContext implements Listener {
private CarbonChat carbonChat;
@Override
public void onEnable() {
saveDefaultConfig();
public mcMMOContext(CarbonChat carbonChat) {
this.carbonChat = carbonChat;
carbonChat = (CarbonChat) Bukkit.getPluginManager().getPlugin("CarbonChat");
carbonChat.getContextManager().register("mcmmo-party", (context) -> {
this.carbonChat.getContextManager().register("mcmmo-party", (context) -> {
if ((context.getValue() instanceof Boolean) && ((Boolean) context.getValue())) {
return isInSameParty(context.getSender(), context.getTarget());
}
return true;
});
Bukkit.getPluginManager().registerEvents(this, this);
}
@EventHandler(ignoreCancelled = true)
@@ -40,6 +33,7 @@ public final class CarbonChatMCMMO extends JavaPlugin implements Listener {
if ((party instanceof Boolean) && ((Boolean) party)) {
if (!isInParty(event.getUser())) {
event.setCancelled(true);
event.setFailureMessage(carbonChat.getConfig().getString("contexts.mcMMO.cancellation-message"));
}
}
}
@@ -22,7 +22,7 @@ public class ChatReloadCommand extends BaseCommand {
carbonChat.getChannelManager().reload();
Component message = carbonChat.getAdventureManager().processMessage(carbonChat.getConfig().getString("language.reloaded"),
Component message = carbonChat.getAdventureManager().processMessage(carbonChat.getLanguage().getString("reloaded"),
"br", "\n");
carbonChat.getAdventureManager().getAudiences().audience(sender).sendMessage(message);
@@ -0,0 +1,50 @@
package net.draycia.carbon.commands;
import co.aikar.commands.BaseCommand;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Default;
import co.aikar.commands.annotation.Dependency;
import net.draycia.carbon.CarbonChat;
import net.draycia.carbon.storage.ChatUser;
import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandAlias("clearchat|cc")
@CommandPermission("carbonchat.clearchat.clear")
public class ClearChatCommand extends BaseCommand {
@Dependency
private CarbonChat carbonChat;
@Default
public void baseCommand(CommandSender issuer) {
String format = carbonChat.getModConfig().getString("clear-chat.message", "");
Component component = carbonChat.getAdventureManager().processMessage(format, "br", "\n");
for (Player player : Bukkit.getOnlinePlayers()) {
if (player.hasPermission("carbonchat.clearchat.exempt")) {
continue;
}
ChatUser audience = carbonChat.getUserService().wrap(player);
for (int i = 0; i < carbonChat.getModConfig().getInt("clear-chat.message-count", 100); i++) {
audience.sendMessage(component);
}
if (player.hasPermission("carbonchat.clearchat.notify")) {
String message = carbonChat.getLanguage().getString("clear-notify");
audience.sendMessage(carbonChat.getAdventureManager().processMessage(message, "player", issuer.getName()));
}
if (player.hasPermission("carbonchat.clearchat.exempt")) {
String message = carbonChat.getLanguage().getString("clear-exempt");
audience.sendMessage(carbonChat.getAdventureManager().processMessage(message, "player", issuer.getName()));
}
}
}
}
@@ -24,16 +24,16 @@ public class IgnoreCommand extends BaseCommand {
if (user.isIgnoringUser(targetUser)) {
user.setIgnoringUser(targetUser, false);
user.sendMessage(processMessage(player, carbonChat.getConfig().getString("language.not-ignoring-user")));
user.sendMessage(processMessage(player, carbonChat.getLanguage().getString("not-ignoring-user")));
} else {
Bukkit.getScheduler().runTaskAsynchronously(carbonChat, () -> {
Permission permission = carbonChat.getPermission();
if (permission.playerHas(null, targetUser.asOfflinePlayer(), "carbonchat.ignore.exempt")) {
user.sendMessage(processMessage(player, carbonChat.getConfig().getString("language.ignore-exempt")));
user.sendMessage(processMessage(player, carbonChat.getLanguage().getString("ignore-exempt")));
} else {
user.setIgnoringUser(targetUser, true);
user.sendMessage(processMessage(player, carbonChat.getConfig().getString("language.ignoring-user")));
user.sendMessage(processMessage(player, carbonChat.getLanguage().getString("ignoring-user")));
}
});
@@ -24,7 +24,7 @@ public class MeCommand extends BaseCommand {
}
String message = String.join(" ", args).replace("</pre>", "");
String format = PlaceholderAPI.setPlaceholders(player, carbonChat.getConfig().getString("language.me"));
String format = PlaceholderAPI.setPlaceholders(player, carbonChat.getLanguage().getString("me"));
if (!player.hasPermission("carbonchat.me.formatting")) {
format = format.replace("<message>", "<pre><message></pre>");
@@ -0,0 +1,54 @@
package net.draycia.carbon.commands;
import co.aikar.commands.annotation.*;
import co.aikar.commands.BaseCommand;
import net.draycia.carbon.CarbonChat;
import net.draycia.carbon.storage.ChatUser;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
@CommandAlias("mute")
@CommandPermission("carbonchat.mute")
public class MuteCommand extends BaseCommand {
@Dependency
private CarbonChat carbonChat;
@Default
@CommandCompletion("@players")
@Syntax("<player>")
public void baseCommand(CommandSender sender, ChatUser targetUser) {
Audience audience = carbonChat.getAdventureManager().getAudiences().audience(sender);
if (targetUser.isMuted()) {
targetUser.setMuted(false);
String format = carbonChat.getLanguage().getString("no-longer-muted");
Component message = carbonChat.getAdventureManager().processMessage(format, "br", "\n",
"player", targetUser.asOfflinePlayer().getName());
audience.sendMessage(message);
} else {
Bukkit.getScheduler().runTaskAsynchronously(carbonChat, () -> {
Permission permission = carbonChat.getPermission();
String format;
if (permission.playerHas(null, targetUser.asOfflinePlayer(), "carbonchat.mute.exempt")) {
format = carbonChat.getLanguage().getString("mute-exempt");
} else {
targetUser.setMuted(true);
format = carbonChat.getLanguage().getString("is-now-muted");
}
Component message = carbonChat.getAdventureManager().processMessage(format, "br", "\n",
"player", targetUser.asOfflinePlayer().getName());
audience.sendMessage(message);
});
}
}
}
@@ -39,9 +39,9 @@ public class NicknameCommand extends BaseCommand {
String message;
if (nickname == null) {
message = carbonChat.getConfig().getString("language.other-nickname-reset");
message = carbonChat.getLanguage().getString("other-nickname-reset");
} else {
message = carbonChat.getConfig().getString("language.other-nickname-set");
message = carbonChat.getLanguage().getString("other-nickname-set");
}
sender.sendMessage(carbonChat.getAdventureManager().processMessage(
@@ -53,9 +53,9 @@ public class NicknameCommand extends BaseCommand {
String message;
if (nickname == null) {
message = carbonChat.getConfig().getString("language.nickname-reset");
message = carbonChat.getLanguage().getString("nickname-reset");
} else {
message = carbonChat.getConfig().getString("language.nickname-set");
message = carbonChat.getLanguage().getString("nickname-set");
}
sender.sendMessage(carbonChat.getAdventureManager().processMessageWithPapi(player,
@@ -24,7 +24,7 @@ public class ReplyCommand extends BaseCommand {
ChatUser user = carbonChat.getUserService().wrap(player);
if (user.getReplyTarget() == null) {
String message = carbonChat.getConfig().getString("language.no-reply-target");
String message = carbonChat.getLanguage().getString("no-reply-target");
Component component = carbonChat.getAdventureManager().processMessage(message, "br", "\n");
user.sendMessage(component);
@@ -35,7 +35,7 @@ public class SetColorCommand extends BaseCommand {
settings.setColor(TextColor.fromHexString(color));
user.sendMessage(carbonChat.getAdventureManager().processMessageWithPapi(player, carbonChat.getConfig().getString("language.channel-color-set"),
user.sendMessage(carbonChat.getAdventureManager().processMessageWithPapi(player, carbonChat.getLanguage().getString("channel-color-set"),
"br", "\n", "color", "<color:" + color + ">", "channel", channel.getName(), "hex", color));
}
@@ -0,0 +1,53 @@
package net.draycia.carbon.commands;
import co.aikar.commands.annotation.*;
import co.aikar.commands.BaseCommand;
import net.draycia.carbon.CarbonChat;
import net.draycia.carbon.storage.ChatUser;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
@CommandAlias("shadowmute|sm|smute")
@CommandPermission("carbonchat.shadowmute")
public class ShadowMuteCommand extends BaseCommand {
@Dependency
private CarbonChat carbonChat;
@Default
@CommandCompletion("@players")
@Syntax("<player>")
public void baseCommand(CommandSender sender, ChatUser targetUser) {
Audience audience = carbonChat.getAdventureManager().getAudiences().audience(sender);
if (targetUser.isShadowMuted()) {
targetUser.setShadowMuted(false);
String format = carbonChat.getLanguage().getString("no-longer-shadow-muted");
Component message = carbonChat.getAdventureManager().processMessage(format, "br", "\n",
"player", targetUser.asOfflinePlayer().getName());
audience.sendMessage(message);
} else {
Bukkit.getScheduler().runTaskAsynchronously(carbonChat, () -> {
Permission permission = carbonChat.getPermission();
String format;
if (permission.playerHas(null, targetUser.asOfflinePlayer(), "carbonchat.shadowmute.exempt")) {
format = carbonChat.getLanguage().getString("shadow-mute-exempt");
} else {
targetUser.setShadowMuted(true);
format = carbonChat.getLanguage().getString("is-now-shadow-muted");
}
Component message = carbonChat.getAdventureManager().processMessage(format, "br", "\n",
"player", targetUser.asOfflinePlayer().getName());
audience.sendMessage(message);
});
}
}
}
@@ -27,10 +27,10 @@ public class SpyChannelCommand extends BaseCommand {
if (settings.isSpying()) {
settings.setSpying(false);
message = carbonChat.getConfig().getString("language.spy-toggled-off");
message = carbonChat.getLanguage().getString("spy-toggled-off");
} else {
settings.setSpying(true);
message = carbonChat.getConfig().getString("language.spy-toggled-on");
message = carbonChat.getLanguage().getString("spy-toggled-on");
}
user.sendMessage(carbonChat.getAdventureManager().processMessageWithPapi(player, message, "br", "\n",
@@ -45,10 +45,10 @@ public class SpyChannelCommand extends BaseCommand {
if (user.isSpyingWhispers()) {
user.setSpyingWhispers(false);
message = carbonChat.getConfig().getString("language.spy-whispers-off");
message = carbonChat.getLanguage().getString("spy-whispers-off");
} else {
user.setSpyingWhispers(true);
message = carbonChat.getConfig().getString("language.spy-whispers-on");
message = carbonChat.getLanguage().getString("spy-whispers-on");
}
user.sendMessage(carbonChat.getAdventureManager().processMessageWithPapi(player, message, "br", "\n"));
@@ -1,26 +1,26 @@
package net.draycia.carbonmoderation.listeners;
package net.draycia.carbon.listeners;
import net.draycia.carbon.CarbonChat;
import net.draycia.carbon.events.PreChatFormatEvent;
import net.draycia.carbonmoderation.CarbonChatModeration;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
public class CapsHandler implements Listener {
private final CarbonChatModeration moderation;
private final CarbonChat carbonChat;
public CapsHandler(CarbonChatModeration moderation) {
this.moderation = moderation;
public CapsHandler(CarbonChat carbonChat) {
this.carbonChat = carbonChat;
}
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onMessage(PreChatFormatEvent event) {
if (!moderation.getConfig().getBoolean("caps-protection.enabled")) {
if (!carbonChat.getModConfig().getBoolean("caps-protection.enabled")) {
return;
}
if (!(event.getMessage().length() >= moderation.getConfig().getInt("caps-protection.minimum-length"))) {
if (!(event.getMessage().length() >= carbonChat.getModConfig().getInt("caps-protection.minimum-length"))) {
return;
}
@@ -34,11 +34,11 @@ public class CapsHandler implements Listener {
double capsPercentage = (amountOfCaps * 100.0) / event.getMessage().length();
if (!(capsPercentage >= moderation.getConfig().getDouble("caps-protection.percent-caps"))) {
if (!(capsPercentage >= carbonChat.getModConfig().getDouble("caps-protection.percent-caps"))) {
return;
}
if (moderation.getConfig().getBoolean("block-message")) {
if (carbonChat.getModConfig().getBoolean("block-message")) {
event.setCancelled(true);
} else {
event.setMessage(event.getMessage().toLowerCase());
@@ -1,8 +1,8 @@
package net.draycia.carbonmoderation.listeners;
package net.draycia.carbon.listeners;
import net.draycia.carbon.CarbonChat;
import net.draycia.carbon.channels.ChatChannel;
import net.draycia.carbon.events.PreChatFormatEvent;
import net.draycia.carbonmoderation.CarbonChatModeration;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.event.EventHandler;
@@ -18,15 +18,15 @@ import java.util.regex.Pattern;
public class FilterHandler implements Listener {
private final CarbonChatModeration moderation;
private final CarbonChat carbonChat;
private final Map<String, List<Pattern>> patternReplacements = new HashMap<>();
private final List<Pattern> blockedWords = new ArrayList<>();
public FilterHandler(CarbonChatModeration moderation) {
this.moderation = moderation;
public FilterHandler(CarbonChat carbonChat) {
this.carbonChat = carbonChat;
FileConfiguration config = moderation.getConfig();
FileConfiguration config = carbonChat.getModConfig();
ConfigurationSection filters = config.getConfigurationSection("filters.filters");
@@ -34,7 +34,7 @@ public class FilterHandler implements Listener {
List<Pattern> patterns = new ArrayList<>();
for (String word : filters.getStringList(replacement)) {
if (moderation.getConfig().getBoolean("filters.case-sensitive")) {
if (carbonChat.getModConfig().getBoolean("filters.case-sensitive")) {
patterns.add(Pattern.compile(word));
} else {
patterns.add(Pattern.compile(word, Pattern.CASE_INSENSITIVE));
@@ -46,7 +46,7 @@ public class FilterHandler implements Listener {
for (String replacement : config.getStringList("filters.blocked-words")) {
for (String word : filters.getStringList(replacement)) {
if (moderation.getConfig().getBoolean("filters.case-sensitive")) {
if (carbonChat.getModConfig().getBoolean("filters.case-sensitive")) {
blockedWords.add(Pattern.compile(word));
} else {
blockedWords.add(Pattern.compile(word, Pattern.CASE_INSENSITIVE));
@@ -57,7 +57,7 @@ public class FilterHandler implements Listener {
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onFilter(PreChatFormatEvent event) {
if (!moderation.getConfig().getBoolean("filters.enabled")) {
if (!carbonChat.getModConfig().getBoolean("filters.enabled")) {
return;
}
@@ -1,4 +1,4 @@
package net.draycia.carbonmoderation.listeners;
package net.draycia.carbon.listeners;
import net.draycia.carbon.events.PreChatFormatEvent;
import org.bukkit.event.EventHandler;
@@ -1,18 +1,18 @@
package net.draycia.carbonmoderation.listeners;
package net.draycia.carbon.listeners;
import net.draycia.carbon.CarbonChat;
import net.draycia.carbon.events.ChatComponentEvent;
import net.draycia.carbon.events.ChatFormatEvent;
import net.draycia.carbonmoderation.CarbonChatModeration;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
public class ShadowMuteHandler implements Listener {
private final CarbonChatModeration moderation;
private final CarbonChat carbonChat;
public ShadowMuteHandler(CarbonChatModeration moderation) {
this.moderation = moderation;
public ShadowMuteHandler(CarbonChat carbonChat) {
this.carbonChat = carbonChat;
}
@EventHandler(priority = EventPriority.LOWEST)
@@ -34,7 +34,7 @@ public class ShadowMuteHandler implements Listener {
return;
}
String prefix = moderation.getConfig().getString("shadow-mute-prefix", "[SM] ");
String prefix = carbonChat.getModConfig().getString("shadow-mute-prefix", "[SM] ");
event.setFormat(prefix + event.getFormat());
}
@@ -23,9 +23,13 @@ public class AdventureManager {
}
public Component processMessage(String input, String... placeholders) {
switch (carbonChat.getConfig().getString("formatting.type", "minimessage").toLowerCase()) {
switch (carbonChat.getLanguage().getString("formatting.type", "minimessage").toLowerCase()) {
case "minedown":
return processMineDown(input, placeholders);
case "mojang":
case "mojangson":
case "json":
return processMojang(input, placeholders);
case "minimessage-markdown":
return MiniMessage.markdown().parse(input, placeholders);
case "minimessage":
@@ -34,6 +38,17 @@ public class AdventureManager {
}
}
private Component processMojang(String input, String... placeholders) {
for (int i = 0; i < placeholders.length; i += 2) {
String placeholder = placeholders[i];
String replacement = placeholders[i+1];
input = input.replace("<" + placeholder + ">", replacement);
}
return getAudiences().gsonSerializer().deserialize(input);
}
private Component processMineDown(String input, String... placeholders) {
return MineDown.parse(input, placeholders);
}
@@ -61,7 +61,7 @@ public class CommandManager {
commandManager.getCommandConditions().addCondition(ChatChannel.class,"canuse", (context, execution, value) -> {
if (value == null) {
throw new ConditionFailedException(carbonChat.getConfig().getString("language.cannot-use-channel"));
throw new ConditionFailedException(carbonChat.getLanguage().getString("cannot-use-channel"));
}
ChatUser user = carbonChat.getUserService().wrap(context.getIssuer().getPlayer());
@@ -73,7 +73,7 @@ public class CommandManager {
commandManager.getCommandConditions().addCondition(ChatChannel.class,"exists", (context, execution, value) -> {
if (value == null) {
throw new ConditionFailedException(carbonChat.getConfig().getString("language.cannot-use-channel"));
throw new ConditionFailedException(carbonChat.getLanguage().getString("cannot-use-channel"));
}
});
@@ -92,6 +92,10 @@ public class CommandManager {
this.commandManager.registerCommand(new ReplyCommand());
this.commandManager.registerCommand(new SetColorCommand());
this.commandManager.registerCommand(new SpyChannelCommand());
this.commandManager.registerCommand(new ClearChatCommand());
this.commandManager.registerCommand(new MuteCommand());
this.commandManager.registerCommand(new ShadowMuteCommand());
}
public BukkitCommandManager getCommandManager() {
@@ -58,7 +58,7 @@ public class MessageManager {
user.setNickname(nickname, true);
if (user.isOnline()) {
String message = carbonChat.getConfig().getString("language.nickname-set");
String message = carbonChat.getLanguage().getString("nickname-set");
user.sendMessage(carbonChat.getAdventureManager().processMessageWithPapi(user.asPlayer(),
message, "nickname", nickname));
@@ -69,7 +69,7 @@ public class MessageManager {
user.setNickname(null, true);
if (user.isOnline()) {
String message = carbonChat.getConfig().getString("language.nickname-reset");
String message = carbonChat.getLanguage().getString("nickname-reset");
user.sendMessage(carbonChat.getAdventureManager().processMessageWithPapi(user.asPlayer(), message));
}
@@ -246,8 +246,8 @@ public class CarbonChatUser implements ChatUser, ForwardingAudience {
return;
}
String toPlayerFormat = carbonChat.getConfig().getString("language.message-to-other");
String fromPlayerFormat = carbonChat.getConfig().getString("language.message-from-other");
String toPlayerFormat = carbonChat.getLanguage().getString("message-to-other");
String fromPlayerFormat = carbonChat.getLanguage().getString("message-from-other");
String senderName = sender.asOfflinePlayer().getName();
String senderOfflineName = senderName;
@@ -325,7 +325,7 @@ public class CarbonChatUser implements ChatUser, ForwardingAudience {
continue;
}
user.sendMessage(carbonChat.getAdventureManager().processMessage(carbonChat.getConfig().getString("language.spy-whispers"),
user.sendMessage(carbonChat.getAdventureManager().processMessage(carbonChat.getLanguage().getString("spy-whispers"),
"br", "\n", "message", message,
"targetname", targetOfflineName, "sendername", senderOfflineName,
"target", targetName, "sender", senderName));
@@ -95,37 +95,11 @@ channels:
should-bungee: false
message-prefix: '!'
# Options:
# 'MiniMessage': https://github.com/KyoriPowered/adventure-docs/blob/feature/minimessage/source/minimessage.rst#the-components
# 'MiniMessage-Markdown': https://github.com/KyoriPowered/adventure-docs/blob/feature/minimessage/source/minimessage.rst#markdown
# 'MineDown': https://github.com/Phoenix616/MineDown#syntax
# Note that the messages provided in the default config utilise MiniMessage, and need to be changed if you're using MineDown
formatting:
type: 'MiniMessage'
language:
# The following messages are only compatible with MiniMessage/MineDown
reloaded: '<yellow>Chat config has been reloaded!'
message-to-other: '<green>[<gray>Me <gold>-> <gray><target><reset><green>] <message>'
message-from-other: '<green>[<gray><sender><reset> <gold>-> <gray>Me<green>] <message>'
spy-whispers: '<yellow>Spy [<gray><sender><reset> <gold>-> <gray><target><reset><yellow>] <message>'
no-reply-target: '<red>You have no one to reply to!'
empty-channel: 'NONE' #<channel>, set to "NONE" to disable
other-nickname-set: '<green><user><reset>''s nickname was set to <nickname><green>!'
other-nickname-reset: '<green><user><reset>''s nickname was reset!'
# The following messages are compatible with PlaceholderAPI and MiniMessage/MineDown
me: '<italic><dark_purple>*<displayname> <reset><message>*</dark_purple></italic>'
ignoring-user: '<green>You are now ignoring <gold><player><reset><green>!'
not-ignoring-user: '<green>You are no longer ignoring <gold><player><reset><green>!'
ignore-exempt: '<red>User <player> <red>is exempt from being ignored!'
channel-color-set: '<green>You have set <color><channel> <green>color to <hex>!'
spy-toggled-on: '<gray>You are now spying on <color><channel> <gray>chat!'
spy-toggled-off: '<gray>You are no longer spying on <color><channel> <gray>chat!'
spy-whispers-on: '<gray>You are now spying on whispers!'
spy-whispers-off: '<gray>You are no longer spying on whispers!'
nickname-set: '<green>Your nickname was set to <nickname><reset><green>!'
nickname-reset: '<green>Your nickname was reset!'
contexts:
Towny:
cancellation-message: '<red>You do not belong to a town!'
mcMMO:
cancellation-message: '<red>You do not have a party!'
# Used for <server> placeholder in channel formats
server-name: 'Server'
+40
View File
@@ -0,0 +1,40 @@
# Options:
# 'MiniMessage': https://docs.adventure.kyori.net/minimessage.html#format
# 'MiniMessage-Markdown': https://docs.adventure.kyori.net/minimessage.html#markdown
# 'MineDown': https://github.com/Phoenix616/MineDown#syntax
# 'JSON': https://minecraft.gamepedia.com/Raw_JSON_text_format
# Note that the messages provided in the default config utilise MiniMessage, and need to be changed if you're using MineDown
# Please DO NOT use JSON formatting unless you really know what you're doing
formatting:
type: 'MiniMessage'
# The following messages are only compatible with MiniMessage/MineDown
reloaded: '<yellow>Chat config has been reloaded!'
message-to-other: '<green>[<gray>Me <gold>-> <gray><target><reset><green>] <message>'
message-from-other: '<green>[<gray><sender><reset> <gold>-> <gray>Me<green>] <message>'
spy-whispers: '<yellow>Spy [<gray><sender><reset> <gold>-> <gray><target><reset><yellow>] <message>'
no-reply-target: '<red>You have no one to reply to!'
empty-channel: 'NONE' #<channel>, set to "NONE" to disable
other-nickname-set: '<green><user><reset>''s nickname was set to <nickname><green>!'
other-nickname-reset: '<green><user><reset>''s nickname was reset!'
# The following messages are compatible with PlaceholderAPI and MiniMessage/MineDown
me: '<italic><dark_purple>*<displayname> <reset><message>*</dark_purple></italic>'
ignoring-user: '<green>You are now ignoring <gold><player><reset><green>!'
not-ignoring-user: '<green>You are no longer ignoring <gold><player><reset><green>!'
ignore-exempt: '<red>User <player> <red>is exempt from being ignored!'
channel-color-set: '<green>You have set <color><channel> <green>color to <hex>!'
spy-toggled-on: '<gray>You are now spying on <color><channel> <gray>chat!'
spy-toggled-off: '<gray>You are no longer spying on <color><channel> <gray>chat!'
spy-whispers-on: '<gray>You are now spying on whispers!'
spy-whispers-off: '<gray>You are no longer spying on whispers!'
nickname-set: '<green>Your nickname was set to <nickname><reset><green>!'
nickname-reset: '<green>Your nickname was reset!'
is-now-shadow-muted: '<yellow>Player <player> is now shadow muted!'
no-longer-shadow-muted: '<yellow>Player <player> is no longer shadow muted!'
shadow-mute-exempt: '<red>Player <player> is exempt from being shadow muted!'
is-now-muted: '<yellow>Player <player> is now muted!'
no-longer-muted: '<yellow>Player <player> is no longer muted!'
mute-exempt: '<red>Player <player> is exempt from being muted!'
clear-notify: '<yellow>Chat has been cleared by <player>.'
clear-exempt: '<yellow>You were exempt from the clear due to your permissions!'
@@ -27,15 +27,4 @@ clear-chat:
# The message sent to clear chat, you probably want to leave this blank
message: ""
# How many messages will be sent in order to clear chat
message-count: 100
language:
is-now-shadow-muted: '<yellow>Player <player> is now shadow muted!'
no-longer-shadow-muted: '<yellow>Player <player> is no longer shadow muted!'
shadow-mute-exempt: '<red>Player <player> is exempt from being shadow muted!'
is-now-muted: '<yellow>Player <player> is now muted!'
no-longer-muted: '<yellow>Player <player> is no longer muted!'
mute-exempt: '<red>Player <player> 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!'
message-count: 100