use of br.net.fabiozumbi12.UltimateChat.Sponge.API.PlayerChangeChannelEvent in project UltimateChat by FabioZumbi12.
the class UCListener method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
UChat.get().getUCLogger().debug("onCommand - Label: " + label + " - CmdName: " + cmd.getName());
if (args.length == 1) {
if (args[0].equalsIgnoreCase("?") || args[0].equalsIgnoreCase("help")) {
sendHelp(sender);
return true;
}
if (args[0].equalsIgnoreCase("reload") && UCPerms.hasPermission(sender, "uchat.cmd.reload")) {
UChat.get().reload();
UChat.get().getLang().sendMessage(sender, "plugin.reloaded");
return true;
}
}
if (sender instanceof Player) {
Player p = (Player) sender;
if (cmd.getName().equalsIgnoreCase("channel")) {
if (args.length == 0) {
UCChannel ch = UChat.get().getChannel(label);
if (ch != null) {
addPlayerToChannel(ch, p);
} else {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.dontexist").replace("{channel}", label));
}
return true;
}
if (args.length >= 1) {
UCChannel ch = UChat.get().getChannel(label);
StringBuilder msgBuild = new StringBuilder();
for (String arg : args) {
msgBuild.append(" ").append(arg);
}
String msg = msgBuild.toString().substring(1);
if (ch != null) {
sendMessageToPlayer(ch, p, args, msg);
return true;
}
}
// if /ch or /channel
if (label.equalsIgnoreCase("ch") || label.equalsIgnoreCase("channel")) {
if (args.length == 1) {
// ch list
if (args[0].equalsIgnoreCase("list")) {
UltimateFancy fancy = new UltimateFancy();
fancy.coloredText("&7------------------------------------------\n");
fancy.coloredText(UChat.get().getLang().get("help.channels.available").replace("{channels}", "")).next();
boolean first = true;
for (UCChannel ch : UChat.get().getChannels().values()) {
if (UCPerms.channelReadPerm(p, ch) && ch.availableInWorld(p.getWorld())) {
if (first) {
fancy.coloredText(ch.getColor() + ch.getName() + "&a");
first = false;
} else {
fancy.coloredText(", " + ch.getColor() + ch.getName() + "&a");
}
fancy.hoverShowText(ch.getColor() + "Alias: " + ch.getAlias()).clickRunCmd("/" + ch.getAlias()).next();
}
}
fancy.coloredText("\n&7------------------------------------------").send(p);
return true;
}
UCChannel ch = UChat.get().getChannel(args[0]);
if (ch == null) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.dontexist").replace("{channel}", args[0]));
return true;
}
if (!UCPerms.channelReadPerm(p, ch) && !UCPerms.channelWritePerm(p, ch)) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.nopermission").replace("{channel}", ch.getName()));
return true;
}
if (!ch.availableInWorld(p.getWorld())) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.notavailable").replace("{channel}", ch.getName()));
return true;
}
if (!ch.canLock()) {
UChat.get().getLang().sendMessage(p, "help.channels.send");
return true;
}
if (ch.isMember(p)) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.alreadyon").replace("{channel}", ch.getName()));
return true;
}
if (!ch.getPassword().isEmpty()) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.password").replace("{channel}", ch.getAlias()));
return true;
}
// listen change channel event
PlayerChangeChannelEvent postEvent = new PlayerChangeChannelEvent(p, UChat.get().getPlayerChannel(p), ch);
Bukkit.getPluginManager().callEvent(postEvent);
if (postEvent.isCancelled()) {
return true;
}
ch.addMember(p);
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.entered").replace("{channel}", ch.getName()));
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.entered").replace("{channel}", ch.getName()));
return true;
}
}
sendChannelHelp(p);
}
// Listen cmd chat/uchat
if (cmd.getName().equalsIgnoreCase("uchat")) {
if (args.length == 1) {
if (args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("?")) {
sendHelp(sender);
return true;
}
if (args[0].equalsIgnoreCase("msgtoggle")) {
if (!UCPerms.cmdPerm(p, "msgtoggle")) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("cmd.nopermission"));
return true;
}
if (UChat.get().msgTogglePlayers.contains(p.getName())) {
UChat.get().msgTogglePlayers.remove(p.getName());
UChat.get().getLang().sendMessage(p, "cmd.msgtoggle.enabled");
} else {
UChat.get().msgTogglePlayers.add(p.getName());
UChat.get().getLang().sendMessage(p, "cmd.msgtoggle.disabled");
}
return true;
}
if (args[0].equalsIgnoreCase("clear")) {
if (!UCPerms.cmdPerm(p, "clear")) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("cmd.nopermission"));
return true;
}
for (int i = 0; i < 100; i++) {
if (!p.isOnline()) {
break;
}
UCUtil.performCommand(p, Bukkit.getConsoleSender(), "tellraw " + p.getName() + " {\"text\":\" \"}");
}
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("cmd.clear.cleared"));
return true;
}
if (args[0].equalsIgnoreCase("clear-all")) {
if (!UCPerms.cmdPerm(p, "clear-all")) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("cmd.nopermission"));
return true;
}
for (Player play : Bukkit.getOnlinePlayers()) {
for (int i = 0; i < 100; i++) {
if (!play.isOnline()) {
continue;
}
UCUtil.performCommand(play, Bukkit.getConsoleSender(), "tellraw " + play.getName() + " {\"text\":\" \"}");
}
}
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("cmd.clear.cleared"));
return true;
}
if (args[0].equalsIgnoreCase("spy")) {
if (!UCPerms.cmdPerm(p, "spy")) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("cmd.nopermission"));
return true;
}
if (!UChat.get().isSpy.contains(p.getName())) {
UChat.get().isSpy.add(p.getName());
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("cmd.spy.enabled"));
} else {
UChat.get().isSpy.remove(p.getName());
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("cmd.spy.disabled"));
}
return true;
}
}
if (args.length == 2) {
// chat msgtoggle <player>
if (args[0].equalsIgnoreCase("msgtoggle")) {
if (!UCPerms.hasPerm(p, "msgtoggle.others")) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("cmd.nopermission"));
return true;
}
Player vict = Bukkit.getPlayer(args[1]);
if (vict != null) {
if (UChat.get().msgTogglePlayers.contains(vict.getName())) {
UChat.get().msgTogglePlayers.remove(vict.getName());
UChat.get().getLang().sendMessage(vict, "cmd.msgtoggle.enabled");
} else {
UChat.get().msgTogglePlayers.add(vict.getName());
UChat.get().getLang().sendMessage(vict, "cmd.msgtoggle.disabled");
}
return true;
}
}
// chat delchannel <channel-name>
if (args[0].equalsIgnoreCase("delchannel")) {
if (!UCPerms.cmdPerm(p, "delchannel")) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("cmd.nopermission"));
return true;
}
UCChannel ch = UChat.get().getChannel(args[1]);
if (ch == null) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.dontexist").replace("{channel}", args[1]));
return true;
}
List<String> toAdd = new ArrayList<>(ch.getMembers());
toAdd.forEach(m -> {
UChat.get().getDefChannel(p.getWorld().getName()).addMember(m);
// listen change channel event
PlayerChangeChannelEvent postEvent = new PlayerChangeChannelEvent(p, null, UChat.get().getDefChannel(p.getWorld().getName()));
Bukkit.getPluginManager().callEvent(postEvent);
});
UChat.get().getUCConfig().delChannel(ch);
UChat.get().registerAliases();
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("cmd.delchannel.success").replace("{channel}", ch.getName()));
return true;
}
// chat ignore <channel/player>
if (args[0].equalsIgnoreCase("ignore")) {
UCChannel ch = UChat.get().getChannel(args[1]);
if (Bukkit.getPlayer(args[1]) != null) {
Player pi = Bukkit.getPlayer(args[1]);
if (!UCPerms.cmdPerm(p, "ignore.player")) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("cmd.nopermission"));
return true;
}
if (!UCPerms.canIgnore(sender, pi)) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("chat.cantignore"));
return true;
}
if (UCMessages.isIgnoringPlayers(p.getName(), pi.getName())) {
UCMessages.unIgnorePlayer(p.getName(), pi.getName());
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("player.unignoring").replace("{player}", pi.getName()));
} else {
UCMessages.ignorePlayer(p.getName(), pi.getName());
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("player.ignoring").replace("{player}", pi.getName()));
}
return true;
} else if (ch != null) {
if (!UCPerms.cmdPerm(p, "ignore.channel")) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("cmd.nopermission"));
return true;
}
if (!UCPerms.canIgnore(sender, ch)) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("chat.cantignore"));
return true;
}
if (ch.isIgnoring(p.getName())) {
ch.unIgnoreThis(p.getName());
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.notignoring").replace("{channel}", ch.getName()));
} else {
ch.ignoreThis(p.getName());
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.ignoring").replace("{channel}", ch.getName()));
}
return true;
} else {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.dontexist").replace("{channel}", args[1]));
return true;
}
}
// chat mute <player>
if (args[0].equalsIgnoreCase("mute")) {
if (!UCPerms.cmdPerm(p, "mute")) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("cmd.nopermission"));
return true;
}
String pname = args[1];
if (Bukkit.getPlayer(args[1]) != null) {
pname = Bukkit.getPlayer(args[1]).getName();
}
if (UChat.get().mutes.contains(pname)) {
UChat.get().mutes.remove(pname);
UChat.get().unMuteInAllChannels(pname);
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.unmuted.all").replace("{player}", pname));
if (Bukkit.getPlayer(pname) != null) {
UChat.get().getLang().sendMessage(Bukkit.getPlayer(args[1]), "channel.player.unmuted.all");
}
} else {
UChat.get().mutes.add(pname);
UChat.get().muteInAllChannels(pname);
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.muted.all").replace("{player}", pname));
if (Bukkit.getPlayer(pname) != null) {
UChat.get().getLang().sendMessage(Bukkit.getPlayer(args[1]), "channel.player.muted.all");
}
}
return true;
}
}
if (args.length == 3) {
// chat tempmute <minutes> <player>
if (args[0].equalsIgnoreCase("tempmute")) {
if (!UCPerms.cmdPerm(p, "tempmute")) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("cmd.nopermission"));
return true;
}
int time = 0;
try {
time = Integer.parseInt(args[1]);
} catch (Exception ex) {
UChat.get().getLang().sendMessage(p, "cmd.tempmute.number");
return true;
}
String pname = args[2];
if (Bukkit.getPlayer(args[2]) != null) {
pname = Bukkit.getPlayer(args[2]).getName();
}
if (UChat.get().mutes.contains(pname)) {
UChat.get().getLang().sendMessage(p, "channel.already.muted");
} else {
UChat.get().mutes.add(pname);
UChat.get().muteInAllChannels(pname);
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.tempmuted.all").replace("{player}", pname).replace("{time}", String.valueOf(time)));
if (Bukkit.getPlayer(pname) != null) {
UChat.get().getLang().sendMessage(Bukkit.getPlayer(args[2]), UChat.get().getLang().get("channel.player.tempmuted.all").replace("{time}", String.valueOf(time)));
}
// mute counter
new MuteCountDown(pname, time).runTaskTimer(UChat.get(), 20, 20);
}
return true;
}
// chat mute <player> <channel>
if (args[0].equalsIgnoreCase("mute")) {
if (!UCPerms.cmdPerm(p, "mute")) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("cmd.nopermission"));
return true;
}
UCChannel ch = UChat.get().getChannel(args[2]);
if (ch == null) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.dontexist").replace("{channel}", args[2]));
return true;
}
String pname = args[1];
if (Bukkit.getPlayer(args[1]) != null) {
pname = Bukkit.getPlayer(args[1]).getName();
}
if (ch.isMuted(pname)) {
ch.unMuteThis(pname);
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.unmuted.this").replace("{player}", pname).replace("{channel}", ch.getName()));
if (Bukkit.getPlayer(pname) != null) {
UChat.get().getLang().sendMessage(Bukkit.getPlayer(args[1]), UChat.get().getLang().get("channel.player.unmuted.this").replace("{channel}", ch.getName()));
}
} else {
ch.muteThis(pname);
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.muted.this").replace("{player}", pname).replace("{channel}", ch.getName()));
if (Bukkit.getPlayer(pname) != null) {
UChat.get().getLang().sendMessage(Bukkit.getPlayer(args[1]), UChat.get().getLang().get("channel.player.muted.this").replace("{channel}", ch.getName()));
}
}
return true;
}
}
if (args.length == 4) {
// chat newchannel <channel-name> <alias> <color>
if (args[0].equalsIgnoreCase("newchannel")) {
if (!UCPerms.cmdPerm(p, "newchannel")) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("cmd.nopermission"));
return true;
}
UCChannel ch = UChat.get().getChannel(args[1]);
if (ch != null) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.alreadyexists").replace("{channel}", ch.getName()));
return true;
}
String color = args[3];
if (color.length() != 2 || !color.matches("(&([A-Fa-fK-Ok-oRr0-9]))$")) {
UChat.get().getLang().sendMessage(p, "channel.invalidcolor");
return true;
}
UCChannel newch = new UCChannel(args[1], args[2], args[3]);
try {
UChat.get().getUCConfig().addChannel(newch);
} catch (IOException e) {
e.printStackTrace();
}
UChat.get().registerAliases();
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("cmd.newchannel.success").replace("{channel}", newch.getName()));
return true;
}
// chat chconfig <channel> <key> <value>
if (args[0].equalsIgnoreCase("chconfig")) {
if (!UCPerms.cmdPerm(p, "chconfig")) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("cmd.nopermission"));
return true;
}
UCChannel ch = UChat.get().getChannel(args[1]);
if (ch == null) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.dontexist").replace("{channel}", args[1]));
return true;
}
if (!ch.getProperties().containsKey(args[2])) {
UChat.get().getLang().sendMessage(p, "cmd.chconfig.invalidkey");
return true;
}
UChat.get().getUCConfig().delChannel(ch);
ch.setProperty(args[2], args[3]);
try {
UChat.get().getUCConfig().addChannel(ch);
} catch (IOException e) {
e.printStackTrace();
}
UChat.get().registerAliases();
UChat.get().getLang().sendMessage(p, "cmd.chconfig.success");
return true;
}
}
}
} else {
if (UChat.get().getChAliases().contains(label.toLowerCase())) {
if (args.length >= 1) {
UCChannel ch = UChat.get().getChannel(label);
StringBuilder msgb = new StringBuilder();
for (String arg : args) {
msgb.append(" ").append(arg);
}
String msg = msgb.toString().substring(1);
UCMessages.sendFancyMessage(new String[0], msg, ch, sender, null);
return true;
}
}
}
if (cmd.getName().equalsIgnoreCase("ubroadcast") && UCPerms.cmdPerm(sender, "broadcast")) {
if (!UCUtil.sendBroadcast(sender, args, false)) {
sendHelp(sender);
}
return true;
}
if (cmd.getName().equalsIgnoreCase("umsg") && UCPerms.cmdPerm(sender, "umsg")) {
if (!UCUtil.sendUmsg(sender, args)) {
sendHelp(sender);
}
return true;
}
if (args.length == 0) {
sender.sendMessage(ChatColor.AQUA + "---------------- " + UChat.get().getPDF().getFullName() + " ----------------");
sender.sendMessage(ChatColor.AQUA + "Developed by " + ChatColor.GOLD + UChat.get().getPDF().getAuthors() + ".");
sender.sendMessage(ChatColor.AQUA + "For more information about the commands, type [" + ChatColor.GOLD + "/" + label + " ?" + ChatColor.AQUA + "].");
sender.sendMessage(ChatColor.AQUA + "---------------------------------------------------");
return true;
} else {
sendHelp(sender);
}
return true;
}
use of br.net.fabiozumbi12.UltimateChat.Sponge.API.PlayerChangeChannelEvent in project UltimateChat by FabioZumbi12.
the class UCListener method addPlayerToChannel.
private void addPlayerToChannel(UCChannel ch, Player p) {
if (!UCPerms.channelReadPerm(p, ch) && !UCPerms.channelWritePerm(p, ch)) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.nopermission").replace("{channel}", ch.getName()));
return;
}
if (!ch.availableInWorld(p.getWorld())) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.notavailable").replace("{channel}", ch.getName()));
return;
}
if (!ch.canLock()) {
UChat.get().getLang().sendMessage(p, "help.channels.send");
return;
}
if (ch.isMember(p)) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.alreadyon").replace("{channel}", ch.getName()));
return;
}
if (!ch.getPassword().isEmpty()) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.password").replace("{channel}", ch.getAlias()));
return;
}
// listen change channel event
PlayerChangeChannelEvent postEvent = new PlayerChangeChannelEvent(p, UChat.get().getPlayerChannel(p), ch);
Bukkit.getPluginManager().callEvent(postEvent);
if (postEvent.isCancelled()) {
return;
}
ch.addMember(p);
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.entered").replace("{channel}", ch.getName()));
}
use of br.net.fabiozumbi12.UltimateChat.Sponge.API.PlayerChangeChannelEvent in project UltimateChat by FabioZumbi12.
the class UCCommands method addPlayerToChannel.
public static void addPlayerToChannel(UCChannel ch, Player src) {
if (!ch.canLock()) {
UChat.get().getLang().sendMessage(src, "help.channels.send");
return;
}
if (ch.isMember(src)) {
UChat.get().tempChannels.put(src.getName(), ch.getAlias());
UChat.get().getLang().sendMessage(src, UChat.get().getLang().get("channel.alreadyon").replace("{channel}", ch.getName()));
return;
}
if (!ch.getPassword().isEmpty()) {
UChat.get().getLang().sendMessage(src, UChat.get().getLang().get("channel.password").replace("{channel}", ch.getAlias()));
return;
}
// fire event
PlayerChangeChannelEvent event = new PlayerChangeChannelEvent((Player) src, UChat.get().getPlayerChannel(src), ch);
Sponge.getEventManager().post(event);
if (event.isCancelled()) {
return;
}
ch.addMember(src);
UChat.get().getLang().sendMessage(src, UChat.get().getLang().get("channel.entered").replace("{channel}", ch.getName()));
}
use of br.net.fabiozumbi12.UltimateChat.Sponge.API.PlayerChangeChannelEvent in project UltimateChat by FabioZumbi12.
the class UCCommands method sendMessageToPlayer.
public static void sendMessageToPlayer(Player src, UCChannel ch, String msg) {
if (UChat.get().mutes.contains(src.getName()) || ch.isMuted(src.getName())) {
if (UChat.get().timeMute.containsKey(src.getName())) {
UChat.get().getLang().sendMessage(src, UChat.get().getLang().get("channel.tempmuted").replace("{time}", String.valueOf(UChat.get().timeMute.get(src.getName()))));
} else {
UChat.get().getLang().sendMessage(src, "channel.muted");
}
return;
}
if (!UChat.get().getPerms().channelWritePerm(src, ch)) {
UChat.get().getLang().sendMessage(src, UChat.get().getLang().get("channel.nopermission").replace("{channel}", ch.getName()));
return;
}
if (!ch.availableInWorld(src.getWorld())) {
UChat.get().getLang().sendMessage(src, UChat.get().getLang().get("channel.notavailable").replace("{channel}", ch.getName()));
return;
}
if (!ch.getPassword().isEmpty() && !ch.isMember(src)) {
if (msg.split(" ").length != 1 || !ch.getPassword().equals(msg.split(" ")[0])) {
UChat.get().getLang().sendMessage(src, UChat.get().getLang().get("channel.password").replace("{channel}", ch.getAlias()));
return;
}
if (!UChat.get().getPerms().hasPerm(src, "password")) {
UChat.get().getLang().sendMessage(src, UChat.get().getLang().get("chat.nopermission"));
return;
}
// fire event
PlayerChangeChannelEvent event = new PlayerChangeChannelEvent((Player) src, UChat.get().getPlayerChannel(src), ch);
Sponge.getEventManager().post(event);
if (event.isCancelled()) {
return;
}
ch.addMember(src);
UChat.get().getLang().sendMessage(src, UChat.get().getLang().get("channel.entered").replace("{channel}", ch.getName()));
return;
}
UChat.get().tempChannels.put(src.getName(), ch.getAlias());
UChat.get().getLogger().timings(UCLogger.timingType.START, "UCListener#sendPreTell()|Fire AsyncPlayerChatEvent");
// run sponge chat event
Text msgt = Text.of(msg);
MessageChannelEvent.Chat event = SpongeEventFactory.createMessageChannelEventChat(UChat.get().getVHelper().getCause(src), src.getMessageChannel(), Optional.of(src.getMessageChannel()), new MessageEvent.MessageFormatter(Text.builder("<" + src.getName() + "> ").onShiftClick(TextActions.insertText(src.getName())).onClick(TextActions.suggestCommand("/msg " + src.getName())).build(), msgt), msgt, false);
Sponge.getEventManager().post(event);
}
use of br.net.fabiozumbi12.UltimateChat.Sponge.API.PlayerChangeChannelEvent in project UltimateChat by FabioZumbi12.
the class UCListener method sendMessageToPlayer.
private void sendMessageToPlayer(UCChannel ch, Player p, String[] args, String msg) {
if (UChat.get().mutes.contains(p.getName()) || ch.isMuted(p.getName())) {
if (UChat.get().timeMute.containsKey(p.getName())) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.tempmuted").replace("{time}", String.valueOf(UChat.get().timeMute.get(p.getName()))));
} else {
UChat.get().getLang().sendMessage(p, "channel.muted");
}
return;
}
if (!UCPerms.channelWritePerm(p, ch)) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.nopermission").replace("{channel}", ch.getName()));
return;
}
if (!ch.getPassword().isEmpty() && !ch.isMember(p)) {
if (args.length != 1 || !ch.getPassword().equals(args[0])) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.password").replace("{channel}", ch.getAlias()));
return;
}
if (!UCPerms.hasPerm(p, "password")) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("chat.nopermission"));
return;
}
// listen change channel event
PlayerChangeChannelEvent postEvent = new PlayerChangeChannelEvent(p, UChat.get().getPlayerChannel(p), ch);
Bukkit.getPluginManager().callEvent(postEvent);
if (postEvent.isCancelled()) {
return;
}
ch.addMember(p);
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.entered").replace("{channel}", ch.getName()));
}
// run bukkit chat event
Set<Player> pls = new HashSet<>(Bukkit.getOnlinePlayers());
UChat.get().tempChannels.put(p.getName(), ch.getAlias());
AsyncPlayerChatEvent event = new AsyncPlayerChatEvent(true, p, msg, pls);
Bukkit.getScheduler().runTaskAsynchronously(UChat.get(), () -> {
UChat.get().getUCLogger().timings(timingType.START, "UCListener#onCommand()|Fire AsyncPlayerChatEvent");
UChat.get().getServer().getPluginManager().callEvent(event);
});
}
Aggregations