Fix moderation.yml and change economy context

This commit is contained in:
Draycia committed 2020-08-21 22:16:01 -07:00
1 parent 66217f6534
commit 69375bbd33
7 files changed
+57 -36

No files matched your search

@@ -1,5 +1,6 @@
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;
@@ -13,6 +14,7 @@ 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;
@@ -104,6 +106,10 @@ public final class CarbonChat extends JavaPlugin {
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
@@ -126,7 +132,6 @@ 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);
@@ -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;
@@ -36,12 +36,12 @@ public class ClearChatCommand extends BaseCommand {
}
if (player.hasPermission("carbonchat.clearchat.notify")) {
String message = carbonChat.getModConfig().getString("language.clear-notify");
String message = carbonChat.getConfig().getString("language.clear-notify");
audience.sendMessage(carbonChat.getAdventureManager().processMessage(message, "player", issuer.getName()));
}
if (player.hasPermission("carbonchat.clearchat.exempt")) {
String message = carbonChat.getModConfig().getString("language.clear-exempt");
String message = carbonChat.getConfig().getString("language.clear-exempt");
audience.sendMessage(carbonChat.getAdventureManager().processMessage(message, "player", issuer.getName()));
}
}
@@ -25,7 +25,7 @@ public class MuteCommand extends BaseCommand {
if (targetUser.isMuted()) {
targetUser.setMuted(false);
String format = carbonChat.getModConfig().getString("language.no-longer-muted");
String format = carbonChat.getConfig().getString("language.no-longer-muted");
Component message = carbonChat.getAdventureManager().processMessage(format, "br", "\n",
"player", targetUser.asOfflinePlayer().getName());
@@ -37,10 +37,10 @@ public class MuteCommand extends BaseCommand {
String format;
if (permission.playerHas(null, targetUser.asOfflinePlayer(), "carbonchat.mute.exempt")) {
format = carbonChat.getModConfig().getString("language.mute-exempt");
format = carbonChat.getConfig().getString("language.mute-exempt");
} else {
targetUser.setMuted(true);
format = carbonChat.getModConfig().getString("language.is-now-muted");
format = carbonChat.getConfig().getString("language.is-now-muted");
}
Component message = carbonChat.getAdventureManager().processMessage(format, "br", "\n",
@@ -25,7 +25,7 @@ public class ShadowMuteCommand extends BaseCommand {
if (targetUser.isShadowMuted()) {
targetUser.setShadowMuted(false);
String format = carbonChat.getModConfig().getString("language.no-longer-shadow-muted");
String format = carbonChat.getConfig().getString("language.no-longer-shadow-muted");
Component message = carbonChat.getAdventureManager().processMessage(format, "br", "\n",
"player", targetUser.asOfflinePlayer().getName());
@@ -37,10 +37,10 @@ public class ShadowMuteCommand extends BaseCommand {
String format;
if (permission.playerHas(null, targetUser.asOfflinePlayer(), "carbonchat.shadowmute.exempt")) {
format = carbonChat.getModConfig().getString("language.shadow-mute-exempt");
format = carbonChat.getConfig().getString("language.shadow-mute-exempt");
} else {
targetUser.setShadowMuted(true);
format = carbonChat.getModConfig().getString("language.is-now-shadow-muted");
format = carbonChat.getConfig().getString("language.is-now-shadow-muted");
}
Component message = carbonChat.getAdventureManager().processMessage(format, "br", "\n",
+8
View File
@@ -126,6 +126,14 @@ language:
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!'
contexts:
Towny:
+30
View File
@@ -0,0 +1,30 @@
caps-protection:
enabled: true
minimum-length: 10
percent-caps: 80
block-message: false
shadow-mute-prefix: '[SM] '
filters:
enabled: true
case-sensitive: false
# The keys ("****" for example) are what the text is replaced with
# The strings in the lists ("lag" etc) are what's replaced
filters:
# In this example, any instance of "lag" or "laggggg" will be replaced with "****"
"****":
- "la[g]+"
- "lag"
# Underscore = blank, empty. The text will basically be removed.
"_":
- "broccoli sucks"
# Anything in blocked-words will prevent the message from being sent at all.
blocked-words:
- "pineapple doesn't belong on pizza"
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