mirror of
https://github.com/Aust1n46/VentureChat.git
synced 2025-05-22 18:09:06 +00:00
Added new API method for getting list of channels.
Added channel tab completion for /mute command.
This commit is contained in:
parent
1da382bb38
commit
72153b57c6
@ -21,8 +21,10 @@ public class ChatChannel {
|
||||
|
||||
private static MineverseChat plugin = MineverseChat.getInstance();
|
||||
private static ChatChannel defaultChatChannel;
|
||||
@Deprecated
|
||||
private static ChatChannel[] channels;
|
||||
private static String defaultColor;
|
||||
private static List<ChatChannel> chatChannels = new ArrayList<ChatChannel>();
|
||||
|
||||
private String name;
|
||||
private String permission;
|
||||
@ -65,6 +67,7 @@ public class ChatChannel {
|
||||
ChatChannel chatChannel = new ChatChannel(name, color, chatColor, permission, speakPermission, mutable,
|
||||
filter, defaultChannel, alias, distance, autojoin, bungee, cooldown, format);
|
||||
channels[counter++] = chatChannel;
|
||||
chatChannels.add(chatChannel);
|
||||
if (defaultChannel) {
|
||||
defaultChatChannel = chatChannel;
|
||||
defaultColor = color;
|
||||
@ -77,9 +80,19 @@ public class ChatChannel {
|
||||
*
|
||||
* @return {@link ChatChannel}[]
|
||||
*/
|
||||
@Deprecated
|
||||
public static ChatChannel[] getChannels() {
|
||||
return channels;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of chat channels.
|
||||
*
|
||||
* @return {@link List}<{@link ChatChannel}>
|
||||
*/
|
||||
public static List<ChatChannel> getChatChannels() {
|
||||
return chatChannels;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a chat channel by name.
|
||||
|
@ -15,7 +15,7 @@ public class Chlist extends MineverseCommand {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String command, String[] args) {
|
||||
sender.sendMessage(LocalizedMessage.CHANNEL_LIST_HEADER.toString());
|
||||
for(ChatChannel chname : ChatChannel.getChannels()) {
|
||||
for(ChatChannel chname : ChatChannel.getChatChannels()) {
|
||||
if(chname.hasPermission()) {
|
||||
if(sender.hasPermission(chname.getPermission())) {
|
||||
sender.sendMessage(LocalizedMessage.CHANNEL_LIST_WITH_PERMISSIONS.toString()
|
||||
|
@ -29,7 +29,7 @@ public class Setchannelall extends MineverseCommand {
|
||||
.replace("{args}", args[0]));
|
||||
return;
|
||||
}
|
||||
for(ChatChannel channel : ChatChannel.getChannels()) {
|
||||
for(ChatChannel channel : ChatChannel.getChatChannels()) {
|
||||
if(channel.hasPermission()) {
|
||||
if(!player.isOnline()) {
|
||||
sender.sendMessage(LocalizedMessage.PLAYER_OFFLINE_NO_PERMISSIONS_CHECK.toString());
|
||||
|
@ -5,6 +5,7 @@ import java.io.DataOutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -120,10 +121,17 @@ public class Mute extends MineverseCommand {
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
|
||||
List<String> completions = new ArrayList<>();
|
||||
StringUtil.copyPartialMatches(args[args.length - 1], MineverseChat.networkPlayerNames, completions);
|
||||
completions.add("tester");
|
||||
Collections.sort(completions);
|
||||
return completions;
|
||||
if(args.length == 1) {
|
||||
StringUtil.copyPartialMatches(args[0], MineverseChat.networkPlayerNames, completions);
|
||||
Collections.sort(completions);
|
||||
return completions;
|
||||
}
|
||||
if(args.length == 2) {
|
||||
StringUtil.copyPartialMatches(args[1], ChatChannel.getChatChannels().stream().map(ChatChannel::getName).collect(Collectors.toList()), completions);
|
||||
Collections.sort(completions);
|
||||
return completions;
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
private void sendBungeeCordMute(CommandSender sender, String playerToMute, ChatChannel channel, long time) {
|
||||
|
@ -31,7 +31,7 @@ public class Muteall extends MineverseCommand {
|
||||
return;
|
||||
}
|
||||
boolean bungee = false;
|
||||
for(ChatChannel channel : ChatChannel.getChannels()) {
|
||||
for(ChatChannel channel : ChatChannel.getChatChannels()) {
|
||||
if(channel.isMutable()) {
|
||||
player.addMute(channel.getName(), 0);
|
||||
if(channel.getBungee()) {
|
||||
|
@ -28,7 +28,7 @@ public class Unmute extends MineverseCommand {
|
||||
sender.sendMessage(LocalizedMessage.PLAYER_OFFLINE.toString().replace("{args}", args[0]));
|
||||
return;
|
||||
}
|
||||
for (ChatChannel channel : ChatChannel.getChannels()) {
|
||||
for (ChatChannel channel : ChatChannel.getChatChannels()) {
|
||||
if (channel.getName().equalsIgnoreCase(args[1]) || channel.getAlias().equalsIgnoreCase(args[1])) {
|
||||
if (!player.isMuted(channel.getName())) {
|
||||
sender.sendMessage(LocalizedMessage.PLAYER_NOT_MUTED.toString()
|
||||
|
@ -31,7 +31,7 @@ public class Unmuteall extends MineverseCommand {
|
||||
return;
|
||||
}
|
||||
boolean bungee = false;
|
||||
for(ChatChannel channel : ChatChannel.getChannels()) {
|
||||
for(ChatChannel channel : ChatChannel.getChatChannels()) {
|
||||
player.removeMute(channel.getName());
|
||||
if(channel.getBungee()) {
|
||||
bungee = true;
|
||||
|
@ -153,7 +153,7 @@ public class CommandListener implements CommandExecutor, Listener {
|
||||
}
|
||||
|
||||
if(!plugin.quickchat) {
|
||||
for(ChatChannel channel : ChatChannel.getChannels()) {
|
||||
for(ChatChannel channel : ChatChannel.getChatChannels()) {
|
||||
if(!channel.hasPermission() || mcp.getPlayer().hasPermission(channel.getPermission())) {
|
||||
if(message.equals("/" + channel.getAlias())) {
|
||||
mcp.getPlayer().sendMessage(LocalizedMessage.SET_CHANNEL.toString()
|
||||
@ -227,7 +227,7 @@ public class CommandListener implements CommandExecutor, Listener {
|
||||
return true;
|
||||
}
|
||||
MineverseChatPlayer mcp = MineverseChatAPI.getOnlineMineverseChatPlayer((Player) sender);
|
||||
for(ChatChannel channel : ChatChannel.getChannels()) {
|
||||
for(ChatChannel channel : ChatChannel.getChatChannels()) {
|
||||
if(command.getName().toLowerCase().equals(channel.getAlias())) {
|
||||
if(args.length == 0) {
|
||||
mcp.getPlayer().sendMessage(ChatColor.RED + "Invalid command: /" + channel.getAlias() + " message");
|
||||
|
Loading…
x
Reference in New Issue
Block a user