mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 22:15:08 +00:00
Fix moderation.yml and change economy context
This commit is contained in:
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);
|
||||
|
||||
+5
-27
@@ -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",
|
||||
|
||||
Reference in new issue
Block a user