mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-26 17:05:01 +00:00
Fix reactions showing up in Discord bridge & colour codes showing up in bridge
This commit is contained in:
parent
6e140ace7d
commit
08115470b0
@ -46,8 +46,13 @@ public class ChatManager extends FreedomService
|
|||||||
private void handleChatEvent(AsyncPlayerChatEvent event)
|
private void handleChatEvent(AsyncPlayerChatEvent event)
|
||||||
{
|
{
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
String message = event.getMessage().trim();
|
String originalMessage = event.getMessage();
|
||||||
|
if (plugin.mu.onPlayerChat(player) || plugin.sh.handlePlayerChat(player, originalMessage))
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String message = originalMessage.trim();
|
||||||
// Format colors and strip &k
|
// Format colors and strip &k
|
||||||
message = FUtil.colorize(message);
|
message = FUtil.colorize(message);
|
||||||
message = message.replaceAll(ChatColor.MAGIC.toString(), "&k");
|
message = message.replaceAll(ChatColor.MAGIC.toString(), "&k");
|
||||||
@ -82,6 +87,8 @@ public class ChatManager extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
plugin.dc.onPlayerChat(player, ChatColor.stripColor(message));
|
||||||
|
|
||||||
// Check for 4chan trigger
|
// Check for 4chan trigger
|
||||||
if (ConfigEntry.FOURCHAN_ENABLED.getBoolean())
|
if (ConfigEntry.FOURCHAN_ENABLED.getBoolean())
|
||||||
{
|
{
|
||||||
|
@ -3,7 +3,6 @@ package me.totalfreedom.totalfreedommod;
|
|||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FSync;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -11,7 +10,6 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
|
||||||
public class Muter extends FreedomService
|
public class Muter extends FreedomService
|
||||||
@ -26,26 +24,23 @@ public class Muter extends FreedomService
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
public boolean onPlayerChat(Player player)
|
||||||
public void onAsyncPlayerChatEvent(AsyncPlayerChatEvent event)
|
|
||||||
{
|
{
|
||||||
Player player = event.getPlayer();
|
|
||||||
|
|
||||||
FPlayer fPlayer = plugin.pl.getPlayerSync(player);
|
FPlayer fPlayer = plugin.pl.getPlayerSync(player);
|
||||||
|
|
||||||
if (!fPlayer.isMuted())
|
if (!fPlayer.isMuted())
|
||||||
{
|
{
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.al.isAdminSync(player))
|
if (plugin.al.isAdminSync(player))
|
||||||
{
|
{
|
||||||
fPlayer.setMuted(false);
|
fPlayer.setMuted(false);
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
player.sendMessage(Component.text("You are muted.", NamedTextColor.RED));
|
player.sendMessage(Component.text("You are muted.", NamedTextColor.RED));
|
||||||
event.setCancelled(true);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
|
@ -514,16 +514,28 @@ public class Discord extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
public void onPlayerChat(Player player, String message)
|
||||||
public void onAsyncPlayerChat(AsyncPlayerChatEvent event)
|
|
||||||
{
|
{
|
||||||
Player player = event.getPlayer();
|
if (ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
|
||||||
String message = event.getMessage();
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!ConfigEntry.ADMIN_ONLY_MODE.getBoolean() && !server.hasWhitelist()
|
if (server.hasWhitelist())
|
||||||
&& !plugin.pl.getPlayer(player).isMuted() && bot != null)
|
|
||||||
{
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (plugin.pl.getPlayer(player).isMuted())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bot == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
messageChatChannel(player.getName() + " \u00BB " + ChatColor.stripColor(message));
|
messageChatChannel(player.getName() + " \u00BB " + ChatColor.stripColor(message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
@ -21,7 +21,6 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
@ -412,23 +411,35 @@ public class Shop extends FreedomService
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
public boolean handlePlayerChat(Player player, String message)
|
||||||
public void onPlayerChat(AsyncPlayerChatEvent event)
|
|
||||||
{
|
{
|
||||||
String message = event.getMessage();
|
if (!ConfigEntry.SHOP_ENABLED.getBoolean())
|
||||||
Player player = event.getPlayer();
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (ConfigEntry.SHOP_ENABLED.getBoolean() && ConfigEntry.SHOP_REACTIONS_ENABLED.getBoolean()
|
if (!ConfigEntry.SHOP_REACTIONS_ENABLED.getBoolean())
|
||||||
&& !plugin.sh.reactionString.isEmpty() && message.equals(plugin.sh.reactionString))
|
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (plugin.sh.reactionString.isEmpty())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!message.equals(plugin.sh.reactionString))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
PlayerData data = plugin.pl.getData(player);
|
PlayerData data = plugin.pl.getData(player);
|
||||||
data.setCoins(data.getCoins() + plugin.sh.coinsPerReactionWin);
|
data.setCoins(data.getCoins() + plugin.sh.coinsPerReactionWin);
|
||||||
plugin.pl.save(data);
|
plugin.pl.save(data);
|
||||||
plugin.sh.endReaction(player.getName());
|
plugin.sh.endReaction(player.getName());
|
||||||
player.sendMessage(ChatColor.GREEN + "You have been given " + ChatColor.GOLD
|
player.sendMessage(ChatColor.GREEN + "You have been given " + ChatColor.GOLD
|
||||||
+ plugin.sh.coinsPerReactionWin + ChatColor.GREEN + " coins!");
|
+ plugin.sh.coinsPerReactionWin + ChatColor.GREEN + " coins!");
|
||||||
}
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ShopItem getShopItem(int slot)
|
public ShopItem getShopItem(int slot)
|
||||||
|
Loading…
Reference in New Issue
Block a user