Cleaned PlayerListener a little bit
This commit is contained in:
parent
cffd2607aa
commit
795eacf38d
5 changed files with 194 additions and 201 deletions
|
@ -1,5 +1,8 @@
|
||||||
package buttondevteam.chat;
|
package buttondevteam.chat;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import buttondevteam.chat.formatting.ChatFormatter;
|
import buttondevteam.chat.formatting.ChatFormatter;
|
||||||
|
|
||||||
public class Channel {
|
public class Channel {
|
||||||
|
@ -7,20 +10,29 @@ public class Channel {
|
||||||
public final ChatFormatter.Color Color;
|
public final ChatFormatter.Color Color;
|
||||||
public final String Command;
|
public final String Command;
|
||||||
|
|
||||||
|
private static List<Channel> channels = new ArrayList<>();
|
||||||
|
|
||||||
public Channel(String displayname, ChatFormatter.Color color, String command) {
|
public Channel(String displayname, ChatFormatter.Color color, String command) {
|
||||||
DisplayName = displayname;
|
DisplayName = displayname;
|
||||||
Color = color;
|
Color = color;
|
||||||
Command = command;
|
Command = command;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Channel GlobalChat = new Channel("§fg§f",
|
static {
|
||||||
ChatFormatter.Color.White, "g");
|
channels.add(GlobalChat = new Channel("§fg§f", ChatFormatter.Color.White, "g"));
|
||||||
public static Channel TownChat = new Channel("§3TC§f",
|
channels.add(TownChat = new Channel("§3TC§f", ChatFormatter.Color.DarkAqua, "tc"));
|
||||||
ChatFormatter.Color.DarkAqua, "tc");
|
channels.add(NationChat = new Channel("§6NC§f", ChatFormatter.Color.Gold, "nc"));
|
||||||
public static Channel NationChat = new Channel("§6NC§f",
|
channels.add(AdminChat = new Channel("§cADMIN§f", ChatFormatter.Color.Red, "a"));
|
||||||
ChatFormatter.Color.Gold, "nc");
|
channels.add(ModChat = new Channel("§9MOD§f", ChatFormatter.Color.Blue, "mod"));
|
||||||
public static Channel AdminChat = new Channel("§cADMIN§f",
|
}
|
||||||
ChatFormatter.Color.Red, "a");
|
|
||||||
public static Channel ModChat = new Channel("§9MOD§f",
|
public static List<Channel> getChannels() {
|
||||||
ChatFormatter.Color.Blue, "mod");
|
return channels;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Channel GlobalChat;
|
||||||
|
public static Channel TownChat;
|
||||||
|
public static Channel NationChat;
|
||||||
|
public static Channel AdminChat;
|
||||||
|
public static Channel ModChat;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ import buttondevteam.chat.formatting.TellrawSerializer;
|
||||||
import buttondevteam.lib.TBMCPlayer;
|
import buttondevteam.lib.TBMCPlayer;
|
||||||
import buttondevteam.chat.formatting.ChatFormatter.Color;
|
import buttondevteam.chat.formatting.ChatFormatter.Color;
|
||||||
import buttondevteam.chat.formatting.ChatFormatter.Priority;
|
import buttondevteam.chat.formatting.ChatFormatter.Priority;
|
||||||
|
import buttondevteam.chat.listener.PlayerListener;
|
||||||
|
|
||||||
public class ChatProcessing {
|
public class ChatProcessing {
|
||||||
private static final Pattern ESCAPE_PATTERN = Pattern.compile("\\\\([\\*\\_\\\\])");
|
private static final Pattern ESCAPE_PATTERN = Pattern.compile("\\\\([\\*\\_\\\\])");
|
||||||
|
@ -47,11 +48,11 @@ public class ChatProcessing {
|
||||||
// Returns e.setCancelled
|
// Returns e.setCancelled
|
||||||
public static boolean ProcessChat(CommandSender sender, String message) {
|
public static boolean ProcessChat(CommandSender sender, String message) {
|
||||||
long processstart = System.nanoTime();
|
long processstart = System.nanoTime();
|
||||||
if (PlayerListener.essentials == null)
|
if (PluginMain.essentials == null)
|
||||||
PlayerListener.essentials = (Essentials) (Bukkit.getPluginManager().getPlugin("Essentials"));
|
PluginMain.essentials = (Essentials) (Bukkit.getPluginManager().getPlugin("Essentials"));
|
||||||
Player player = (sender instanceof Player ? (Player) sender : null);
|
Player player = (sender instanceof Player ? (Player) sender : null);
|
||||||
|
|
||||||
if (player != null && PlayerListener.essentials.getUser(player).isMuted())
|
if (player != null && PluginMain.essentials.getUser(player).isMuted())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
ChatPlayer mp = null;
|
ChatPlayer mp = null;
|
||||||
|
@ -157,7 +158,7 @@ public class ChatProcessing {
|
||||||
else
|
else
|
||||||
p.playSound(p.getLocation(), PlayerListener.NotificationSound, 1.0f,
|
p.playSound(p.getLocation(), PlayerListener.NotificationSound, 1.0f,
|
||||||
(float) PlayerListener.NotificationPitch);
|
(float) PlayerListener.NotificationPitch);
|
||||||
return PlayerListener.essentials.getUser(p).getNickname();
|
return PluginMain.essentials.getUser(p).getNickname();
|
||||||
}
|
}
|
||||||
Bukkit.getServer().getLogger().warning(
|
Bukkit.getServer().getLogger().warning(
|
||||||
"Player nicknamed " + match + " not found in nickname map but was reported as online.");
|
"Player nicknamed " + match + " not found in nickname map but was reported as online.");
|
||||||
|
|
|
@ -17,10 +17,12 @@ import org.htmlcleaner.TagNode;
|
||||||
|
|
||||||
import buttondevteam.chat.commands.CommandCaller;
|
import buttondevteam.chat.commands.CommandCaller;
|
||||||
import buttondevteam.chat.commands.YeehawCommand;
|
import buttondevteam.chat.commands.YeehawCommand;
|
||||||
|
import buttondevteam.chat.listener.PlayerListener;
|
||||||
import buttondevteam.lib.TBMCCoreAPI;
|
import buttondevteam.lib.TBMCCoreAPI;
|
||||||
import buttondevteam.lib.TBMCPlayer;
|
import buttondevteam.lib.TBMCPlayer;
|
||||||
import buttondevteam.lib.chat.TBMCChatAPI;
|
import buttondevteam.lib.chat.TBMCChatAPI;
|
||||||
|
|
||||||
|
import com.earth2me.essentials.Essentials;
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
|
@ -108,6 +110,7 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15.
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean stop = false;
|
public Boolean stop = false;
|
||||||
|
public static Essentials essentials = null;
|
||||||
|
|
||||||
// Fired when plugin is disabled
|
// Fired when plugin is disabled
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -0,0 +1,126 @@
|
||||||
|
package buttondevteam.chat.listener;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Timer;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
|
import com.earth2me.essentials.Essentials;
|
||||||
|
|
||||||
|
import buttondevteam.chat.ChatPlayer;
|
||||||
|
import buttondevteam.chat.FlairStates;
|
||||||
|
import buttondevteam.chat.PlayerJoinTimerTask;
|
||||||
|
import buttondevteam.chat.PluginMain;
|
||||||
|
import buttondevteam.lib.TBMCPlayerAddEvent;
|
||||||
|
import buttondevteam.lib.TBMCPlayerJoinEvent;
|
||||||
|
import buttondevteam.lib.TBMCPlayerLoadEvent;
|
||||||
|
import buttondevteam.lib.TBMCPlayerSaveEvent;
|
||||||
|
|
||||||
|
public class PlayerJoinLeaveListener implements Listener {
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerLoad(TBMCPlayerLoadEvent e) {
|
||||||
|
ChatPlayer cp = e.GetPlayer().asPluginPlayer(ChatPlayer.class);
|
||||||
|
cp.FlairUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerTBMCJoin(TBMCPlayerJoinEvent e) {
|
||||||
|
if (PluginMain.essentials == null)
|
||||||
|
PluginMain.essentials = ((Essentials) Bukkit.getPluginManager().getPlugin("Essentials"));
|
||||||
|
ChatPlayer cp = e.GetPlayer().asPluginPlayer(ChatPlayer.class);
|
||||||
|
Player p = Bukkit.getPlayer(cp.getUuid());
|
||||||
|
|
||||||
|
if (!cp.getFlairState().equals(FlairStates.NoComment)) {
|
||||||
|
PluginMain.ConfirmUserMessage(cp);
|
||||||
|
Timer timer = new Timer();
|
||||||
|
PlayerJoinTimerTask tt = new PlayerJoinTimerTask() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
p.setPlayerListName(p.getName() + mp.GetFormattedFlair());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
tt.mp = cp;
|
||||||
|
timer.schedule(tt, 1000);
|
||||||
|
} else {
|
||||||
|
if (cp.getFlairTime() == 0x00)
|
||||||
|
cp.SetFlair(ChatPlayer.FlairTimeNone);
|
||||||
|
Timer timer = new Timer();
|
||||||
|
PlayerJoinTimerTask tt = new PlayerJoinTimerTask() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Player player = Bukkit.getPlayer(mp.getPlayerName());
|
||||||
|
if (player == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (mp.getFlairState().equals(FlairStates.NoComment)) {
|
||||||
|
String json = String.format(
|
||||||
|
"[\"\",{\"text\":\"If you're from Reddit and you'd like your /r/TheButton flair displayed ingame, write your Minecraft name to \",\"color\":\"aqua\"},{\"text\":\"[this thread].\",\"color\":\"aqua\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"%s\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"Click here to go to the Reddit thread\",\"color\":\"aqua\"}]}}}]",
|
||||||
|
PluginMain.FlairThreadURL);
|
||||||
|
PluginMain.Instance.getServer().dispatchCommand(PluginMain.Console,
|
||||||
|
"tellraw " + mp.getPlayerName() + " " + json);
|
||||||
|
json = "[\"\",{\"text\":\"If you aren't from Reddit or don't want the flair, type /u ignore to prevent this message after next login.\",\"color\":\"aqua\"}]";
|
||||||
|
PluginMain.Instance.getServer().dispatchCommand(PluginMain.Console,
|
||||||
|
"tellraw " + mp.getPlayerName() + " " + json);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
tt.mp = cp;
|
||||||
|
timer.schedule(tt, 15 * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
String nwithoutformatting = PluginMain.essentials.getUser(p).getNickname();
|
||||||
|
int index;
|
||||||
|
if (nwithoutformatting != null) {
|
||||||
|
while ((index = nwithoutformatting.indexOf("§k")) != -1)
|
||||||
|
nwithoutformatting = nwithoutformatting.replace("§k" + nwithoutformatting.charAt(index + 2), ""); // Support for one random char
|
||||||
|
while ((index = nwithoutformatting.indexOf('§')) != -1)
|
||||||
|
nwithoutformatting = nwithoutformatting.replace("§" + nwithoutformatting.charAt(index + 1), "");
|
||||||
|
} else
|
||||||
|
nwithoutformatting = p.getName();
|
||||||
|
PlayerListener.nicknames.put(nwithoutformatting, p.getUniqueId());
|
||||||
|
|
||||||
|
cp.RPMode = true;
|
||||||
|
|
||||||
|
cp.FlairUpdate();
|
||||||
|
|
||||||
|
if (cp.ChatOnly || p.getGameMode().equals(GameMode.SPECTATOR)) {
|
||||||
|
cp.ChatOnly = false;
|
||||||
|
p.setGameMode(GameMode.SURVIVAL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerSave(TBMCPlayerSaveEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerAdd(TBMCPlayerAddEvent event) {
|
||||||
|
ChatPlayer cp = event.GetPlayer().asPluginPlayer(ChatPlayer.class);
|
||||||
|
cp.SetFlair(ChatPlayer.FlairTimeNone);
|
||||||
|
cp.setFlairState(FlairStates.NoComment);
|
||||||
|
cp.setUserNames(new ArrayList<>());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerLeave(PlayerQuitEvent event) {
|
||||||
|
String deletenick = null;
|
||||||
|
for (String nickname : PlayerListener.nicknames.keySet()) {
|
||||||
|
UUID uuid = PlayerListener.nicknames.get(nickname);
|
||||||
|
if (event.getPlayer().getUniqueId().equals(uuid)) {
|
||||||
|
deletenick = nickname;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (deletenick != null)
|
||||||
|
PlayerListener.nicknames.remove(deletenick);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,6 +1,5 @@
|
||||||
package buttondevteam.chat;
|
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,7 +9,6 @@ import java.util.UUID;
|
||||||
import com.palmergames.bukkit.towny.Towny;
|
import com.palmergames.bukkit.towny.Towny;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
@ -25,7 +23,6 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
import org.bukkit.event.server.ServerCommandEvent;
|
import org.bukkit.event.server.ServerCommandEvent;
|
||||||
import org.bukkit.help.HelpTopic;
|
import org.bukkit.help.HelpTopic;
|
||||||
|
@ -35,16 +32,14 @@ import org.bukkit.potion.PotionEffect;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
import au.com.mineauz.minigames.MinigamePlayer;
|
import au.com.mineauz.minigames.MinigamePlayer;
|
||||||
import au.com.mineauz.minigames.Minigames;
|
import au.com.mineauz.minigames.Minigames;
|
||||||
|
import buttondevteam.chat.Channel;
|
||||||
|
import buttondevteam.chat.ChatPlayer;
|
||||||
|
import buttondevteam.chat.ChatProcessing;
|
||||||
|
import buttondevteam.chat.PluginMain;
|
||||||
import buttondevteam.chat.commands.ucmds.KittycannonCommand;
|
import buttondevteam.chat.commands.ucmds.KittycannonCommand;
|
||||||
import buttondevteam.lib.TBMCPlayer;
|
import buttondevteam.lib.TBMCPlayer;
|
||||||
import buttondevteam.lib.TBMCPlayer.InfoTarget;
|
import buttondevteam.lib.TBMCPlayer.InfoTarget;
|
||||||
import buttondevteam.lib.TBMCPlayerAddEvent;
|
|
||||||
import buttondevteam.lib.TBMCPlayerGetInfoEvent;
|
import buttondevteam.lib.TBMCPlayerGetInfoEvent;
|
||||||
import buttondevteam.lib.TBMCPlayerJoinEvent;
|
|
||||||
import buttondevteam.lib.TBMCPlayerLoadEvent;
|
|
||||||
import buttondevteam.lib.TBMCPlayerSaveEvent;
|
|
||||||
|
|
||||||
import com.earth2me.essentials.Essentials;
|
|
||||||
import com.google.common.collect.BiMap;
|
import com.google.common.collect.BiMap;
|
||||||
import com.google.common.collect.HashBiMap;
|
import com.google.common.collect.HashBiMap;
|
||||||
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
|
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
|
||||||
|
@ -67,112 +62,12 @@ public class PlayerListener implements Listener {
|
||||||
|
|
||||||
public static int LoginWarningCountTotal = 5;
|
public static int LoginWarningCountTotal = 5;
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerLoad(TBMCPlayerLoadEvent e) {
|
|
||||||
ChatPlayer cp = e.GetPlayer().asPluginPlayer(ChatPlayer.class);
|
|
||||||
cp.FlairUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerTBMCJoin(TBMCPlayerJoinEvent e) {
|
|
||||||
if (essentials == null)
|
|
||||||
essentials = ((Essentials) Bukkit.getPluginManager().getPlugin("Essentials"));
|
|
||||||
ChatPlayer cp = e.GetPlayer().asPluginPlayer(ChatPlayer.class);
|
|
||||||
Player p = Bukkit.getPlayer(cp.getUuid());
|
|
||||||
|
|
||||||
if (!cp.getFlairState().equals(FlairStates.NoComment)) {
|
|
||||||
PluginMain.ConfirmUserMessage(cp);
|
|
||||||
Timer timer = new Timer();
|
|
||||||
PlayerJoinTimerTask tt = new PlayerJoinTimerTask() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
p.setPlayerListName(p.getName() + mp.GetFormattedFlair());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
tt.mp = cp;
|
|
||||||
timer.schedule(tt, 1000);
|
|
||||||
} else {
|
|
||||||
if (cp.getFlairTime() == 0x00)
|
|
||||||
cp.SetFlair(ChatPlayer.FlairTimeNone);
|
|
||||||
Timer timer = new Timer();
|
|
||||||
PlayerJoinTimerTask tt = new PlayerJoinTimerTask() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
Player player = Bukkit.getPlayer(mp.getPlayerName());
|
|
||||||
if (player == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (mp.getFlairState().equals(FlairStates.NoComment)) {
|
|
||||||
String json = String.format(
|
|
||||||
"[\"\",{\"text\":\"If you're from Reddit and you'd like your /r/TheButton flair displayed ingame, write your Minecraft name to \",\"color\":\"aqua\"},{\"text\":\"[this thread].\",\"color\":\"aqua\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"%s\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"Click here to go to the Reddit thread\",\"color\":\"aqua\"}]}}}]",
|
|
||||||
PluginMain.FlairThreadURL);
|
|
||||||
PluginMain.Instance.getServer().dispatchCommand(PluginMain.Console,
|
|
||||||
"tellraw " + mp.getPlayerName() + " " + json);
|
|
||||||
json = "[\"\",{\"text\":\"If you aren't from Reddit or don't want the flair, type /u ignore to prevent this message after next login.\",\"color\":\"aqua\"}]";
|
|
||||||
PluginMain.Instance.getServer().dispatchCommand(PluginMain.Console,
|
|
||||||
"tellraw " + mp.getPlayerName() + " " + json);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
tt.mp = cp;
|
|
||||||
timer.schedule(tt, 15 * 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
String nwithoutformatting = essentials.getUser(p).getNickname();
|
|
||||||
int index;
|
|
||||||
if (nwithoutformatting != null) {
|
|
||||||
while ((index = nwithoutformatting.indexOf("§k")) != -1)
|
|
||||||
nwithoutformatting = nwithoutformatting.replace("§k" + nwithoutformatting.charAt(index + 2), ""); // Support for one random char
|
|
||||||
while ((index = nwithoutformatting.indexOf('§')) != -1)
|
|
||||||
nwithoutformatting = nwithoutformatting.replace("§" + nwithoutformatting.charAt(index + 1), "");
|
|
||||||
} else
|
|
||||||
nwithoutformatting = p.getName();
|
|
||||||
nicknames.put(nwithoutformatting, p.getUniqueId());
|
|
||||||
|
|
||||||
cp.RPMode = true;
|
|
||||||
|
|
||||||
cp.FlairUpdate();
|
|
||||||
|
|
||||||
if (cp.ChatOnly || p.getGameMode().equals(GameMode.SPECTATOR)) {
|
|
||||||
cp.ChatOnly = false;
|
|
||||||
p.setGameMode(GameMode.SURVIVAL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerSave(TBMCPlayerSaveEvent e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerAdd(TBMCPlayerAddEvent event) {
|
|
||||||
ChatPlayer cp = event.GetPlayer().asPluginPlayer(ChatPlayer.class);
|
|
||||||
cp.SetFlair(ChatPlayer.FlairTimeNone);
|
|
||||||
cp.setFlairState(FlairStates.NoComment);
|
|
||||||
cp.setUserNames(new ArrayList<>());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerLeave(PlayerQuitEvent event) {
|
|
||||||
String deletenick = null;
|
|
||||||
for (String nickname : nicknames.keySet()) {
|
|
||||||
UUID uuid = nicknames.get(nickname);
|
|
||||||
if (event.getPlayer().getUniqueId().equals(uuid)) {
|
|
||||||
deletenick = nickname;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (deletenick != null)
|
|
||||||
nicknames.remove(deletenick);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String NotificationSound;
|
public static String NotificationSound;
|
||||||
public static double NotificationPitch;
|
public static double NotificationPitch;
|
||||||
|
|
||||||
public static boolean ShowRPTag = false;
|
public static boolean ShowRPTag = false;
|
||||||
|
|
||||||
public static Essentials essentials = null;
|
public final static String[] LaughStrings = new String[] { "xd", "lel", "lawl", "kek", "lmao", "hue", "hah" };
|
||||||
final static String[] LaughStrings = new String[] { "xd", "lel", "lawl", "kek", "lmao", "hue", "hah" };
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
||||||
|
@ -190,69 +85,24 @@ public class PlayerListener implements Listener {
|
||||||
String cmd = "";
|
String cmd = "";
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
cmd = event.getMessage().substring(1);
|
cmd = event.getMessage().substring(1);
|
||||||
if (cmd.equalsIgnoreCase(Channel.GlobalChat.Command)) {
|
for (Channel channel : Channel.getChannels()) {
|
||||||
mp.CurrentChannel = Channel.GlobalChat;
|
if (cmd.equalsIgnoreCase(channel.Command)) {
|
||||||
event.getPlayer().sendMessage("§6You are now talking in: §b" + mp.CurrentChannel.DisplayName);
|
if (mp.CurrentChannel.equals(channel))
|
||||||
event.setCancelled(true);
|
|
||||||
} else if (cmd.equalsIgnoreCase(Channel.TownChat.Command)) {
|
|
||||||
if (mp.CurrentChannel.equals(Channel.TownChat))
|
|
||||||
mp.CurrentChannel = Channel.GlobalChat;
|
mp.CurrentChannel = Channel.GlobalChat;
|
||||||
else
|
else
|
||||||
mp.CurrentChannel = Channel.TownChat;
|
mp.CurrentChannel = channel;
|
||||||
event.getPlayer().sendMessage("§6You are now talking in: §b" + mp.CurrentChannel.DisplayName);
|
|
||||||
event.setCancelled(true);
|
|
||||||
} else if (cmd.equalsIgnoreCase(Channel.NationChat.Command)) {
|
|
||||||
if (mp.CurrentChannel.equals(Channel.NationChat))
|
|
||||||
mp.CurrentChannel = Channel.GlobalChat;
|
|
||||||
else
|
|
||||||
mp.CurrentChannel = Channel.NationChat;
|
|
||||||
event.getPlayer().sendMessage("§6You are now talking in: §b" + mp.CurrentChannel.DisplayName);
|
|
||||||
event.setCancelled(true);
|
|
||||||
} else if (cmd.equalsIgnoreCase(Channel.AdminChat.Command)) {
|
|
||||||
if (mp.CurrentChannel.equals(Channel.AdminChat))
|
|
||||||
mp.CurrentChannel = Channel.GlobalChat;
|
|
||||||
else
|
|
||||||
mp.CurrentChannel = Channel.AdminChat;
|
|
||||||
event.getPlayer().sendMessage("§6You are now talking in: §b" + mp.CurrentChannel.DisplayName);
|
|
||||||
event.setCancelled(true);
|
|
||||||
} else if (cmd.equalsIgnoreCase(Channel.ModChat.Command)) {
|
|
||||||
if (mp.CurrentChannel.equals(Channel.ModChat))
|
|
||||||
mp.CurrentChannel = Channel.GlobalChat;
|
|
||||||
else
|
|
||||||
mp.CurrentChannel = Channel.ModChat;
|
|
||||||
event.getPlayer().sendMessage("§6You are now talking in: §b" + mp.CurrentChannel.DisplayName);
|
event.getPlayer().sendMessage("§6You are now talking in: §b" + mp.CurrentChannel.DisplayName);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cmd = event.getMessage().substring(1, index);
|
cmd = event.getMessage().substring(1, index);
|
||||||
if (cmd.equalsIgnoreCase(Channel.GlobalChat.Command)) {
|
for (Channel channel : Channel.getChannels()) {
|
||||||
|
if (cmd.equalsIgnoreCase(channel.Command)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
Channel c = mp.CurrentChannel;
|
Channel c = mp.CurrentChannel;
|
||||||
mp.CurrentChannel = Channel.GlobalChat;
|
mp.CurrentChannel = channel;
|
||||||
event.getPlayer().chat(event.getMessage().substring(index + 1));
|
|
||||||
mp.CurrentChannel = c;
|
|
||||||
} else if (cmd.equalsIgnoreCase(Channel.TownChat.Command)) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
Channel c = mp.CurrentChannel;
|
|
||||||
mp.CurrentChannel = Channel.TownChat;
|
|
||||||
event.getPlayer().chat(event.getMessage().substring(index + 1));
|
|
||||||
mp.CurrentChannel = c;
|
|
||||||
} else if (cmd.equalsIgnoreCase(Channel.NationChat.Command)) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
Channel c = mp.CurrentChannel;
|
|
||||||
mp.CurrentChannel = Channel.NationChat;
|
|
||||||
event.getPlayer().chat(event.getMessage().substring(index + 1));
|
|
||||||
mp.CurrentChannel = c;
|
|
||||||
} else if (cmd.equalsIgnoreCase(Channel.AdminChat.Command)) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
Channel c = mp.CurrentChannel;
|
|
||||||
mp.CurrentChannel = Channel.AdminChat;
|
|
||||||
event.getPlayer().chat(event.getMessage().substring(index + 1));
|
|
||||||
mp.CurrentChannel = c;
|
|
||||||
} else if (cmd.equalsIgnoreCase(Channel.ModChat.Command)) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
Channel c = mp.CurrentChannel;
|
|
||||||
mp.CurrentChannel = Channel.ModChat;
|
|
||||||
event.getPlayer().chat(event.getMessage().substring(index + 1));
|
event.getPlayer().chat(event.getMessage().substring(index + 1));
|
||||||
mp.CurrentChannel = c;
|
mp.CurrentChannel = c;
|
||||||
} else if (cmd.equalsIgnoreCase("tpahere")) {
|
} else if (cmd.equalsIgnoreCase("tpahere")) {
|
||||||
|
@ -261,7 +111,7 @@ public class PlayerListener implements Listener {
|
||||||
player.sendMessage("§b" + event.getPlayer().getDisplayName() + " §bis in this world: "
|
player.sendMessage("§b" + event.getPlayer().getDisplayName() + " §bis in this world: "
|
||||||
+ event.getPlayer().getWorld().getName());
|
+ event.getPlayer().getWorld().getName());
|
||||||
} else if (cmd.equalsIgnoreCase("minecraft:me")) {
|
} else if (cmd.equalsIgnoreCase("minecraft:me")) {
|
||||||
if (!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())
|
for (Player p : PluginMain.GetPlayers())
|
||||||
|
@ -269,7 +119,8 @@ public class PlayerListener implements Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cmd.equalsIgnoreCase("sethome")) {
|
}
|
||||||
|
if (cmd.equalsIgnoreCase("sethome")) { // TODO: Move out?
|
||||||
TownyUniverse tu = PluginMain.Instance.TU;
|
TownyUniverse tu = PluginMain.Instance.TU;
|
||||||
try {
|
try {
|
||||||
TownBlock tb = WorldCoord.parseWorldCoord(event.getPlayer()).getTownBlock();
|
TownBlock tb = WorldCoord.parseWorldCoord(event.getPlayer()).getTownBlock();
|
||||||
|
@ -349,9 +200,9 @@ public class PlayerListener implements Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean ActiveF = false;
|
public static boolean ActiveF = false;
|
||||||
static int FCount = 0;
|
public static int FCount = 0;
|
||||||
static ChatPlayer FPlayer = null;
|
public static ChatPlayer FPlayer = null;
|
||||||
private Timer Ftimer;
|
private Timer Ftimer;
|
||||||
public static int AlphaDeaths;
|
public static int AlphaDeaths;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue