Mostly fixed chat formatting #60
10 changed files with 79 additions and 84 deletions
Binary file not shown.
6
pom.xml
6
pom.xml
|
@ -159,12 +159,6 @@
|
||||||
<version>1.6</version>
|
<version>1.6</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/org.javassist/javassist -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.javassist</groupId>
|
|
||||||
<artifactId>javassist</artifactId>
|
|
||||||
<version>3.20.0-GA</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<artifactId>ButtonChat</artifactId>
|
<artifactId>ButtonChat</artifactId>
|
||||||
<organization>
|
<organization>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package buttondevteam.chat;
|
package buttondevteam.chat;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
public class AnnouncerThread {
|
public class AnnouncerThread {
|
||||||
private static int AnnounceMessageIndex = 0;
|
private static int AnnounceMessageIndex = 0;
|
||||||
|
@ -13,9 +13,7 @@ public class AnnouncerThread {
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
}
|
}
|
||||||
if (PluginMain.AnnounceMessages.size() > AnnounceMessageIndex) {
|
if (PluginMain.AnnounceMessages.size() > AnnounceMessageIndex) {
|
||||||
for (Player player : PluginMain.GetPlayers())
|
Bukkit.broadcastMessage(PluginMain.AnnounceMessages.get(AnnounceMessageIndex));
|
||||||
player.sendMessage(PluginMain.AnnounceMessages
|
|
||||||
.get(AnnounceMessageIndex));
|
|
||||||
AnnounceMessageIndex++;
|
AnnounceMessageIndex++;
|
||||||
if (AnnounceMessageIndex == PluginMain.AnnounceMessages.size())
|
if (AnnounceMessageIndex == PluginMain.AnnounceMessages.size())
|
||||||
AnnounceMessageIndex = 0;
|
AnnounceMessageIndex = 0;
|
||||||
|
|
|
@ -38,7 +38,10 @@ public class ChatPlayer extends TBMCPlayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public FlairStates getFlairState() {
|
public FlairStates getFlairState() {
|
||||||
return getEnumData(FlairStates.class);
|
FlairStates data = getEnumData(FlairStates.class);
|
||||||
|
if (data == null)
|
||||||
|
setFlairState(data = FlairStates.NoComment);
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFlairState(FlairStates state) {
|
public void setFlairState(FlairStates state) {
|
||||||
|
@ -70,7 +73,6 @@ public class ChatPlayer extends TBMCPlayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean RPMode = true;
|
public boolean RPMode = true;
|
||||||
public boolean PressedF;
|
|
||||||
public Location SavedLocation;
|
public Location SavedLocation;
|
||||||
public boolean Working;
|
public boolean Working;
|
||||||
// public int Tables = 10;
|
// public int Tables = 10;
|
||||||
|
|
|
@ -75,7 +75,7 @@ public class ChatProcessing {
|
||||||
.setOpenlink("https://twitter.com/hashtag/$1").setPriority(Priority.High).build());
|
.setOpenlink("https://twitter.com/hashtag/$1").setPriority(Priority.High).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns e.setCancelled
|
// Returns e.setCancelled for custom event
|
||||||
public static boolean ProcessChat(Channel channel, CommandSender sender, String message) {
|
public static boolean ProcessChat(Channel channel, CommandSender sender, String message) {
|
||||||
long processstart = System.nanoTime();
|
long processstart = System.nanoTime();
|
||||||
if (PluginMain.essentials == null)
|
if (PluginMain.essentials == null)
|
||||||
|
@ -85,18 +85,12 @@ public class ChatProcessing {
|
||||||
if (player != null && PluginMain.essentials.getUser(player).isMuted())
|
if (player != null && PluginMain.essentials.getUser(player).isMuted())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
if (PlayerListener.ActiveF && !PlayerListener.Fs.contains(sender) && message.equalsIgnoreCase("F"))
|
||||||
|
PlayerListener.Fs.add(sender);
|
||||||
|
|
||||||
ChatPlayer mp = null;
|
ChatPlayer mp = null;
|
||||||
if (player != null) {
|
if (player != null)
|
||||||
mp = TBMCPlayer.getPlayer(player).asPluginPlayer(ChatPlayer.class);
|
mp = TBMCPlayer.getPlayer(player).asPluginPlayer(ChatPlayer.class);
|
||||||
if (message.equalsIgnoreCase("F")) {
|
|
||||||
if (!mp.PressedF && PlayerListener.ActiveF) {
|
|
||||||
PlayerListener.FCount++;
|
|
||||||
mp.PressedF = true;
|
|
||||||
if (PlayerListener.FPlayer != null && PlayerListener.FPlayer.getFCount() < Integer.MAX_VALUE - 1)
|
|
||||||
PlayerListener.FPlayer.setFCount(PlayerListener.FPlayer.getFCount() + 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String msg = message.toLowerCase();
|
String msg = message.toLowerCase();
|
||||||
if (msg.contains("lol")) {
|
if (msg.contains("lol")) {
|
||||||
|
@ -132,22 +126,30 @@ public class ChatProcessing {
|
||||||
|
|
||||||
String suggestmsg = formattedmessage;
|
String suggestmsg = formattedmessage;
|
||||||
|
|
||||||
if (PluginMain.GetPlayers().size() > 0) {
|
if (Bukkit.getOnlinePlayers().size() > 0) {
|
||||||
StringBuilder namesb = new StringBuilder();
|
StringBuilder namesb = new StringBuilder();
|
||||||
namesb.append("(?i)(");
|
namesb.append("(?i)(");
|
||||||
for (Player p : PluginMain.GetPlayers())
|
for (Player p : Bukkit.getOnlinePlayers())
|
||||||
namesb.append(p.getName()).append("|");
|
namesb.append(p.getName()).append("|");
|
||||||
namesb.deleteCharAt(namesb.length() - 1);
|
namesb.deleteCharAt(namesb.length() - 1);
|
||||||
namesb.append(")");
|
namesb.append(")");
|
||||||
StringBuilder nicksb = new StringBuilder();
|
StringBuilder nicksb = new StringBuilder();
|
||||||
nicksb.append("(?i)(");
|
nicksb.append("(?i)(");
|
||||||
for (Player p : PluginMain.GetPlayers()) {
|
{
|
||||||
|
final int size = Bukkit.getOnlinePlayers().size();
|
||||||
|
int index = 0;
|
||||||
|
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||||
final String nick = PlayerListener.nicknames.inverse().get(p.getUniqueId());
|
final String nick = PlayerListener.nicknames.inverse().get(p.getUniqueId());
|
||||||
if (nick != null) // Not everyone has a nickname
|
if (nick != null) {
|
||||||
nicksb.append(nick).append("|");
|
nicksb.append(nick);
|
||||||
|
if (index < size - 1) {
|
||||||
|
nicksb.append("|");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
index++;
|
||||||
}
|
}
|
||||||
nicksb.deleteCharAt(nicksb.length() - 1);
|
|
||||||
nicksb.append(")");
|
nicksb.append(")");
|
||||||
|
}
|
||||||
|
|
||||||
formatters.add(new ChatFormatterBuilder().setRegex(Pattern.compile(namesb.toString())).setColor(Color.Aqua)
|
formatters.add(new ChatFormatterBuilder().setRegex(Pattern.compile(namesb.toString())).setColor(Color.Aqua)
|
||||||
.setOnmatch((String match) -> {
|
.setOnmatch((String match) -> {
|
||||||
|
@ -196,9 +198,10 @@ public class ChatProcessing {
|
||||||
json.addExtra(new TellrawPart("[C]").setHoverEvent(
|
json.addExtra(new TellrawPart("[C]").setHoverEvent(
|
||||||
TellrawEvent.create(TellrawEvent.HoverAC, TellrawEvent.HoverAction.SHOW_TEXT, "Chat only")));
|
TellrawEvent.create(TellrawEvent.HoverAC, TellrawEvent.HoverAction.SHOW_TEXT, "Chat only")));
|
||||||
}
|
}
|
||||||
|
final String channelidentifier = ("[" + (sender instanceof IDiscordSender ? "d|" : "") + currentchannel.DisplayName)
|
||||||
|
+ "]" + (mp != null && !mp.RPMode ? "[OOC]" : "");
|
||||||
json.addExtra(
|
json.addExtra(
|
||||||
new TellrawPart(("[" + (sender instanceof IDiscordSender ? "d|" : "") + currentchannel.DisplayName)
|
new TellrawPart(channelidentifier).setHoverEvent(
|
||||||
+ "]" + (mp != null && !mp.RPMode ? "[OOC]" : "")).setHoverEvent(
|
|
||||||
TellrawEvent.create(TellrawEvent.HoverAC, TellrawEvent.HoverAction.SHOW_TEXT,
|
TellrawEvent.create(TellrawEvent.HoverAC, TellrawEvent.HoverAction.SHOW_TEXT,
|
||||||
new TellrawPart((sender instanceof IDiscordSender ? "From Discord\n" : "")
|
new TellrawPart((sender instanceof IDiscordSender ? "From Discord\n" : "")
|
||||||
+ "Copy message").setColor(Color.Blue)))
|
+ "Copy message").setColor(Color.Blue)))
|
||||||
|
@ -260,7 +263,7 @@ public class ChatProcessing {
|
||||||
sender.sendMessage("§cYou are not a player!");
|
sender.sendMessage("§cYou are not a player!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
for (Player p : PluginMain.GetPlayers()) {
|
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||||
try {
|
try {
|
||||||
Resident resident = PluginMain.Instance.TU.getResidentMap().get(p.getName().toLowerCase());
|
Resident resident = PluginMain.Instance.TU.getResidentMap().get(p.getName().toLowerCase());
|
||||||
if (resident != null && !resident.getName().equals(player.getName())
|
if (resident != null && !resident.getName().equals(player.getName())
|
||||||
|
@ -291,7 +294,7 @@ public class ChatProcessing {
|
||||||
index = PluginMain.Instance.Towns.size() - 1;
|
index = PluginMain.Instance.Towns.size() - 1;
|
||||||
}
|
}
|
||||||
Objective obj = PluginMain.SB.getObjective("town");
|
Objective obj = PluginMain.SB.getObjective("town");
|
||||||
for (Player p : PluginMain.GetPlayers()) {
|
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||||
try {
|
try {
|
||||||
if (town.getResidents().stream().anyMatch(r -> r.getName().equalsIgnoreCase(p.getName())))
|
if (town.getResidents().stream().anyMatch(r -> r.getName().equalsIgnoreCase(p.getName())))
|
||||||
obj.getScore(p.getName()).setScore(index);
|
obj.getScore(p.getName()).setScore(index);
|
||||||
|
@ -331,7 +334,7 @@ public class ChatProcessing {
|
||||||
index = PluginMain.Instance.Nations.size() - 1;
|
index = PluginMain.Instance.Nations.size() - 1;
|
||||||
}
|
}
|
||||||
Objective obj = PluginMain.SB.getObjective("nation");
|
Objective obj = PluginMain.SB.getObjective("nation");
|
||||||
for (Player p : PluginMain.GetPlayers()) {
|
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||||
try {
|
try {
|
||||||
if (nation.getResidents().stream().anyMatch(r -> r.getName().equalsIgnoreCase(p.getName())))
|
if (nation.getResidents().stream().anyMatch(r -> r.getName().equalsIgnoreCase(p.getName())))
|
||||||
obj.getScore(p.getName()).setScore(index);
|
obj.getScore(p.getName()).setScore(index);
|
||||||
|
@ -348,7 +351,7 @@ public class ChatProcessing {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Objective obj = PluginMain.SB.getObjective("admin");
|
Objective obj = PluginMain.SB.getObjective("admin");
|
||||||
for (Player p : PluginMain.GetPlayers()) {
|
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||||
if (p.isOp())
|
if (p.isOp())
|
||||||
obj.getScore(p.getName()).setScore(1);
|
obj.getScore(p.getName()).setScore(1);
|
||||||
else
|
else
|
||||||
|
@ -362,7 +365,7 @@ public class ChatProcessing {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Objective obj = PluginMain.SB.getObjective("mod");
|
Objective obj = PluginMain.SB.getObjective("mod");
|
||||||
for (Player p : PluginMain.GetPlayers()) {
|
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||||
if (PluginMain.permission.playerInGroup(p, "mod"))
|
if (PluginMain.permission.playerInGroup(p, "mod"))
|
||||||
obj.getScore(p.getName()).setScore(1);
|
obj.getScore(p.getName()).setScore(1);
|
||||||
else
|
else
|
||||||
|
@ -379,12 +382,11 @@ public class ChatProcessing {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
PluginMain.Instance.getServer().getConsoleSender()
|
PluginMain.Instance.getServer().getConsoleSender()
|
||||||
.sendMessage(String.format("[%s] <%s%s> %s", currentchannel.DisplayName,
|
.sendMessage(String.format("%s <%s> %s", channelidentifier,
|
||||||
(player != null ? player.getDisplayName() : sender.getName()),
|
(player != null ? player.getDisplayName() : sender.getName()), message));
|
||||||
(mp != null ? mp.GetFormattedFlair() : ""), message));
|
|
||||||
DebugCommand.SendDebugMessage(
|
DebugCommand.SendDebugMessage(
|
||||||
"-- Full ChatProcessing time: " + (System.nanoTime() - processstart) / 1000000f + " ms");
|
"-- Full ChatProcessing time: " + (System.nanoTime() - processstart) / 1000000f + " ms");
|
||||||
DebugCommand.SendDebugMessage("-- ChatFormatter.Combine time: " + combinetime / 1000000f + " ms");
|
DebugCommand.SendDebugMessage("-- ChatFormatter.Combine time: " + combinetime / 1000000f + " ms");
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,6 @@ import java.net.URLConnection;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -253,10 +252,6 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15.
|
||||||
p.sendMessage("§9A Reddit user commented your name. Is that you?§r §6Type /u accept or /u ignore§r");
|
p.sendMessage("§9A Reddit user commented your name. Is that you?§r §6Type /u accept or /u ignore§r");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Collection<? extends Player> GetPlayers() {
|
|
||||||
return Instance.getServer().getOnlinePlayers();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ArrayList<String> AnnounceMessages = new ArrayList<>();
|
public static ArrayList<String> AnnounceMessages = new ArrayList<>();
|
||||||
public static int AnnounceTime = 15 * 60 * 1000;
|
public static int AnnounceTime = 15 * 60 * 1000;
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@ import org.bukkit.entity.Player;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
import buttondevteam.chat.PluginMain;
|
|
||||||
import buttondevteam.lib.chat.TBMCCommandBase;
|
import buttondevteam.lib.chat.TBMCCommandBase;
|
||||||
|
|
||||||
public final class UnlolCommand extends TBMCCommandBase {
|
public final class UnlolCommand extends TBMCCommandBase {
|
||||||
|
@ -31,9 +30,7 @@ public final class UnlolCommand extends TBMCCommandBase {
|
||||||
String msg = (sender instanceof Player ? ((Player) sender).getDisplayName() : sender.getName())
|
String msg = (sender instanceof Player ? ((Player) sender).getDisplayName() : sender.getName())
|
||||||
+ (Lastlolornot ? " unlolled " : " unlaughed ")
|
+ (Lastlolornot ? " unlolled " : " unlaughed ")
|
||||||
+ (Lastlol instanceof Player ? ((Player) Lastlol).getDisplayName() : Lastlol.getName());
|
+ (Lastlol instanceof Player ? ((Player) Lastlol).getDisplayName() : Lastlol.getName());
|
||||||
for (Player pl : PluginMain.GetPlayers())
|
Bukkit.broadcastMessage(msg);
|
||||||
pl.sendMessage(msg);
|
|
||||||
Bukkit.getServer().getConsoleSender().sendMessage(msg);
|
|
||||||
Lastlol = null;
|
Lastlol = null;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -4,7 +4,6 @@ import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import buttondevteam.chat.PluginMain;
|
|
||||||
import buttondevteam.lib.TBMCYEEHAWEvent;
|
import buttondevteam.lib.TBMCYEEHAWEvent;
|
||||||
import buttondevteam.lib.chat.TBMCCommandBase;
|
import buttondevteam.lib.chat.TBMCCommandBase;
|
||||||
|
|
||||||
|
@ -19,12 +18,11 @@ public class YeehawCommand extends TBMCCommandBase {
|
||||||
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
|
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
|
||||||
final String message = "§b* "
|
final String message = "§b* "
|
||||||
+ (sender instanceof Player ? ((Player) sender).getDisplayName() : sender.getName()) + " §bYEEHAWs.";
|
+ (sender instanceof Player ? ((Player) sender).getDisplayName() : sender.getName()) + " §bYEEHAWs.";
|
||||||
for (Player p : PluginMain.GetPlayers()) {
|
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||||
p.playSound(p.getLocation(), "tbmc.yeehaw", 1f, 1f);
|
p.playSound(p.getLocation(), "tbmc.yeehaw", 1f, 1f);
|
||||||
p.sendMessage(message);
|
|
||||||
} // Even a cmdblock could yeehaw in theory
|
} // Even a cmdblock could yeehaw in theory
|
||||||
// Or anyone from Discord
|
// Or anyone from Discord
|
||||||
Bukkit.getConsoleSender().sendMessage(message);
|
Bukkit.broadcastMessage(message);
|
||||||
Bukkit.getPluginManager().callEvent(new TBMCYEEHAWEvent(sender));
|
Bukkit.getPluginManager().callEvent(new TBMCYEEHAWEvent(sender));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,10 +35,15 @@ public final class HelpCommand extends UCommandBase {
|
||||||
ArrayList<String> text = new ArrayList<String>();
|
ArrayList<String> text = new ArrayList<String>();
|
||||||
text.add("§6---- Command list ----");
|
text.add("§6---- Command list ----");
|
||||||
for (TBMCCommandBase cmd : TBMCChatAPI.GetCommands().values())
|
for (TBMCCommandBase cmd : TBMCChatAPI.GetCommands().values())
|
||||||
if (!cmd.GetCommandPath().contains(" "))
|
|
||||||
if (!cmd.GetModOnly() || PluginMain.permission.has(sender, "tbmc.admin"))
|
if (!cmd.GetModOnly() || PluginMain.permission.has(sender, "tbmc.admin"))
|
||||||
if (!cmd.GetPlayerOnly() || sender instanceof Player)
|
if (!cmd.GetPlayerOnly() || sender instanceof Player)
|
||||||
|
if (!cmd.GetCommandPath().contains(" "))
|
||||||
text.add("/" + cmd.GetCommandPath());
|
text.add("/" + cmd.GetCommandPath());
|
||||||
|
else {
|
||||||
|
final String topcmd = cmd.GetCommandPath().substring(0, cmd.GetCommandPath().indexOf(' '));
|
||||||
|
if (!text.contains("/" + topcmd))
|
||||||
|
text.add("/" + topcmd);
|
||||||
|
}
|
||||||
sender.sendMessage(text.toArray(new String[text.size()]));
|
sender.sendMessage(text.toArray(new String[text.size()]));
|
||||||
} else if (args[0].equalsIgnoreCase("colors")) {
|
} else if (args[0].equalsIgnoreCase("colors")) {
|
||||||
sender.sendMessage(new String[] { "§6---- Chat colors/formats ----", //
|
sender.sendMessage(new String[] { "§6---- Chat colors/formats ----", //
|
||||||
|
@ -65,7 +70,8 @@ public final class HelpCommand extends UCommandBase {
|
||||||
if (subcmds.length > 0)
|
if (subcmds.length > 0)
|
||||||
sender.sendMessage(subcmds);
|
sender.sendMessage(subcmds);
|
||||||
else
|
else
|
||||||
sender.sendMessage(new String[] { "§cError: Command not found or you don't have permission for it: " + path,
|
sender.sendMessage(
|
||||||
|
new String[] { "§cError: Command not found or you don't have permission for it: " + path,
|
||||||
"Usage example: /u accept --> /u help u accept" });
|
"Usage example: /u accept --> /u help u accept" });
|
||||||
} else
|
} else
|
||||||
sender.sendMessage(cmd.GetHelpText(args[0]));
|
sender.sendMessage(cmd.GetHelpText(args[0]));
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package buttondevteam.chat.listener;
|
package buttondevteam.chat.listener;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
|
@ -10,6 +11,7 @@ import com.palmergames.bukkit.towny.Towny;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
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;
|
||||||
|
@ -28,6 +30,7 @@ import buttondevteam.chat.ChatPlayer;
|
||||||
import buttondevteam.chat.ChatProcessing;
|
import buttondevteam.chat.ChatProcessing;
|
||||||
import buttondevteam.chat.PluginMain;
|
import buttondevteam.chat.PluginMain;
|
||||||
import buttondevteam.lib.TBMCChatEvent;
|
import buttondevteam.lib.TBMCChatEvent;
|
||||||
|
import buttondevteam.lib.TBMCCoreAPI;
|
||||||
import buttondevteam.lib.TBMCPlayer;
|
import buttondevteam.lib.TBMCPlayer;
|
||||||
import buttondevteam.lib.TBMCPlayer.InfoTarget;
|
import buttondevteam.lib.TBMCPlayer.InfoTarget;
|
||||||
import buttondevteam.lib.chat.Channel;
|
import buttondevteam.lib.chat.Channel;
|
||||||
|
@ -62,14 +65,14 @@ public class PlayerListener implements Listener {
|
||||||
|
|
||||||
public final static String[] LaughStrings = new String[] { "xd", "lel", "lawl", "kek", "lmao", "hue", "hah" };
|
public final static String[] LaughStrings = new String[] { "xd", "lel", "lawl", "kek", "lmao", "hue", "hah" };
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
||||||
if (event.isCancelled())
|
if (event.isCancelled())
|
||||||
return;
|
return;
|
||||||
TBMCChatAPI.SendChatMessage(
|
TBMCChatAPI.SendChatMessage(
|
||||||
TBMCPlayer.getPlayer(event.getPlayer()).asPluginPlayer(ChatPlayer.class).CurrentChannel,
|
TBMCPlayer.getPlayer(event.getPlayer()).asPluginPlayer(ChatPlayer.class).CurrentChannel,
|
||||||
event.getPlayer(), event.getMessage());
|
event.getPlayer(), event.getMessage());
|
||||||
event.setCancelled(true);
|
event.setCancelled(true); // The custom event should only be cancelled when muted or similar
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
|
@ -110,8 +113,7 @@ public class PlayerListener implements Listener {
|
||||||
if (!PluginMain.essentials.getUser(event.getPlayer()).isMuted()) {
|
if (!PluginMain.essentials.getUser(event.getPlayer()).isMuted()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
String message = event.getMessage().substring(index + 1);
|
String message = event.getMessage().substring(index + 1);
|
||||||
for (Player p : PluginMain.GetPlayers())
|
Bukkit.broadcastMessage(String.format("* %s %s", event.getPlayer().getDisplayName(), message));
|
||||||
p.sendMessage(String.format("* %s %s", event.getPlayer().getDisplayName(), message));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -166,10 +168,7 @@ public class PlayerListener implements Listener {
|
||||||
}
|
}
|
||||||
if (target != null) {
|
if (target != null) {
|
||||||
target.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 10 * 20, 5, false, false));
|
target.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 10 * 20, 5, false, false));
|
||||||
for (Player pl : PluginMain.GetPlayers())
|
Bukkit.broadcastMessage(
|
||||||
pl.sendMessage(
|
|
||||||
event.getPlayer().getDisplayName() + " un" + s + "'d " + target.getDisplayName());
|
|
||||||
Bukkit.getServer().getConsoleSender().sendMessage(
|
|
||||||
event.getPlayer().getDisplayName() + " un" + s + "'d " + target.getDisplayName());
|
event.getPlayer().getDisplayName() + " un" + s + "'d " + target.getDisplayName());
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
@ -197,10 +196,10 @@ public class PlayerListener implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean ActiveF = false;
|
public static boolean ActiveF = false;
|
||||||
public static int FCount = 0;
|
|
||||||
public static ChatPlayer FPlayer = null;
|
public static ChatPlayer FPlayer = null;
|
||||||
private Timer Ftimer;
|
private Timer Ftimer;
|
||||||
public static int AlphaDeaths;
|
public static int AlphaDeaths;
|
||||||
|
public static ArrayList<CommandSender> Fs = new ArrayList<>();
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerDeath(PlayerDeathEvent e) {
|
public void onPlayerDeath(PlayerDeathEvent e) {
|
||||||
|
@ -211,24 +210,21 @@ public class PlayerListener implements Listener {
|
||||||
if (Ftimer != null)
|
if (Ftimer != null)
|
||||||
Ftimer.cancel();
|
Ftimer.cancel();
|
||||||
ActiveF = true;
|
ActiveF = true;
|
||||||
FCount = 0;
|
Fs.clear();
|
||||||
FPlayer = TBMCPlayer.getPlayer(e.getEntity().getUniqueId()).asPluginPlayer(ChatPlayer.class);
|
FPlayer = TBMCPlayer.getPlayer(e.getEntity().getUniqueId()).asPluginPlayer(ChatPlayer.class);
|
||||||
FPlayer.setFDeaths(FPlayer.getFDeaths() + 1);
|
FPlayer.setFDeaths(FPlayer.getFDeaths() + 1);
|
||||||
for (Player p : PluginMain.GetPlayers()) {
|
Bukkit.broadcastMessage("§bPress F to pay respects.§r");
|
||||||
ChatPlayer mp = TBMCPlayer.getPlayerAs(p.getUniqueId(), ChatPlayer.class);
|
|
||||||
mp.PressedF = false;
|
|
||||||
p.sendMessage("§bPress F to pay respects.§r");
|
|
||||||
}
|
|
||||||
Ftimer = new Timer();
|
Ftimer = new Timer();
|
||||||
TimerTask tt = new TimerTask() {
|
TimerTask tt = new TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (ActiveF) {
|
if (ActiveF) {
|
||||||
ActiveF = false;
|
ActiveF = false;
|
||||||
for (Player p : PluginMain.GetPlayers()) {
|
if (FPlayer != null && FPlayer.getFCount() < Integer.MAX_VALUE - 1)
|
||||||
p.sendMessage("§b" + FCount + " " + (FCount == 1 ? "person" : "people")
|
FPlayer.setFCount(FPlayer.getFCount() + Fs.size());
|
||||||
|
Bukkit.broadcastMessage("§b" + Fs.size() + " " + (Fs.size() == 1 ? "person" : "people")
|
||||||
+ " paid their respects.§r");
|
+ " paid their respects.§r");
|
||||||
}
|
Fs.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -314,10 +310,7 @@ public class PlayerListener implements Listener {
|
||||||
}
|
}
|
||||||
if (target != null) {
|
if (target != null) {
|
||||||
target.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 10 * 20, 5, false, false));
|
target.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 10 * 20, 5, false, false));
|
||||||
for (Player pl : PluginMain.GetPlayers())
|
Bukkit.broadcastMessage(event.getSender().getName() + " un" + s + "'d " + target.getDisplayName());
|
||||||
pl.sendMessage(event.getSender().getName() + " un" + s + "'d " + target.getDisplayName());
|
|
||||||
Bukkit.getServer().getConsoleSender()
|
|
||||||
.sendMessage(event.getSender().getName() + " un" + s + "'d " + target.getDisplayName());
|
|
||||||
event.setCommand("dontrunthiscmd");
|
event.setCommand("dontrunthiscmd");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -337,6 +330,16 @@ public class PlayerListener implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerTBMCChat(TBMCChatEvent e) {
|
public void onPlayerTBMCChat(TBMCChatEvent e) {
|
||||||
ChatProcessing.ProcessChat(e.getChannel(), e.getSender(), e.getMessage());
|
try {
|
||||||
|
e.setCancelled(ChatProcessing.ProcessChat(e.getChannel(), e.getSender(), e.getMessage()));
|
||||||
|
} catch (Exception ex) {
|
||||||
|
for (Player p : Bukkit.getOnlinePlayers())
|
||||||
|
p.sendMessage("§c!§r["
|
||||||
|
+ e.getChannel().DisplayName + "] <" + (e.getSender() instanceof Player
|
||||||
|
? ((Player) e.getSender()).getDisplayName() : e.getSender().getName())
|
||||||
|
+ "> " + e.getMessage());
|
||||||
|
TBMCCoreAPI.SendException("An error occured while processing a chat message!", ex);
|
||||||
|
e.setCancelled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue