• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Server类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中de.btobastian.javacord.entities.Server的典型用法代码示例。如果您正苦于以下问题:Java Server类的具体用法?Java Server怎么用?Java Server使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Server类属于de.btobastian.javacord.entities包,在下文中一共展示了Server类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: handleServerTextChannel

import de.btobastian.javacord.entities.Server; //导入依赖的package包/类
/**
 * Handles the server text channels.
 *
 * @param packet The packet (the "d"-object).
 * @param server The server of the channel.
 */
private void handleServerTextChannel(JSONObject packet, Server server) {
    if (server.getChannelById(packet.getString("id")) != null) {
        return;
    }
    final Channel channel = new ImplChannel(packet, (ImplServer) server, api);
    listenerExecutorService.submit(new Runnable() {
        @Override
        public void run() {
            List<ChannelCreateListener> listeners = api.getListeners(ChannelCreateListener.class);
            synchronized (listeners) {
                for (ChannelCreateListener listener : listeners) {
                    try {
                        listener.onChannelCreate(api, channel);
                    } catch (Throwable t) {
                        logger.warn("Uncaught exception in ChannelCreateListener!", t);
                    }
                }
            }
        }
    });
}
 
开发者ID:BtoBastian,项目名称:Javacord,代码行数:28,代码来源:ChannelCreateHandler.java


示例2: handleServerVoiceChannel

import de.btobastian.javacord.entities.Server; //导入依赖的package包/类
/**
 * Handles the server voice channels.
 *
 * @param packet The packet (the "d"-object).
 * @param server The server of the channel.
 */
private void handleServerVoiceChannel(JSONObject packet, Server server) {
    if (server.getVoiceChannelById(packet.getString("id")) != null) {
        return;
    }
    final VoiceChannel channel = new ImplVoiceChannel(packet, (ImplServer) server, api);
    listenerExecutorService.submit(new Runnable() {
        @Override
        public void run() {
            List<VoiceChannelCreateListener> listeners = api.getListeners(VoiceChannelCreateListener.class);
            synchronized (listeners) {
                for (VoiceChannelCreateListener listener : listeners) {
                    try {
                        listener.onVoiceChannelCreate(api, channel);
                    } catch (Throwable t) {
                        logger.warn("Uncaught exception in VoiceChannelCreateListener!", t);
                    }
                }
            }
        }
    });
}
 
开发者ID:BtoBastian,项目名称:Javacord,代码行数:28,代码来源:ChannelCreateHandler.java


示例3: handleServerTextChannel

import de.btobastian.javacord.entities.Server; //导入依赖的package包/类
/**
 * Handles the server text channels.
 *
 * @param packet The packet (the "d"-object).
 * @param server The server of the channel.
 */
private void handleServerTextChannel(JSONObject packet, Server server) {
    final Channel channel = server.getChannelById(packet.getString("id"));
    if (channel == null) {
        return;
    }
    ((ImplServer) server).removeChannel(channel);
    listenerExecutorService.submit(new Runnable() {
        @Override
        public void run() {
            List<ChannelDeleteListener> listeners = api.getListeners(ChannelDeleteListener.class);
            synchronized (listeners) {
                for (ChannelDeleteListener listener : listeners) {
                    try {
                        listener.onChannelDelete(api, channel);
                    } catch (Throwable t) {
                        logger.warn("Uncaught exception in ChannelDeleteListener!", t);
                    }
                }
            }
        }
    });
}
 
开发者ID:BtoBastian,项目名称:Javacord,代码行数:29,代码来源:ChannelDeleteHandler.java


示例4: handleServerVoiceChannel

import de.btobastian.javacord.entities.Server; //导入依赖的package包/类
/**
 * Handles the server voice channels.
 *
 * @param packet The packet (the "d"-object).
 * @param server The server of the channel.
 */
private void handleServerVoiceChannel(JSONObject packet, Server server) {
    final VoiceChannel channel = server.getVoiceChannelById(packet.getString("id"));
    if (channel == null) {
        return;
    }
    ((ImplServer) server).removeVoiceChannel(channel);
    listenerExecutorService.submit(new Runnable() {
        @Override
        public void run() {
            List<VoiceChannelDeleteListener> listeners = api.getListeners(VoiceChannelDeleteListener.class);
            synchronized (listeners) {
                for (VoiceChannelDeleteListener listener : listeners) {
                    try {
                        listener.onVoiceChannelDelete(api, channel);
                    } catch (Throwable t) {
                        logger.warn("Uncaught exception in VoiceChannelDeleteListener!", t);
                    }
                }
            }
        }
    });
}
 
开发者ID:BtoBastian,项目名称:Javacord,代码行数:29,代码来源:ChannelDeleteHandler.java


示例5: handle

import de.btobastian.javacord.entities.Server; //导入依赖的package包/类
@Override
public void handle(JSONObject packet) {
    final Server server = api.getServerById(packet.getString("id"));
    if (server == null) {
        return;
    }
    api.getServerMap().remove(server.getId());
    listenerExecutorService.submit(new Runnable() {
        @Override
        public void run() {
            List<ServerLeaveListener> listeners = api.getListeners(ServerLeaveListener.class);
            synchronized (listeners) {
                for (ServerLeaveListener listener : listeners) {
                    try {
                        listener.onServerLeave(api, server);
                    } catch (Throwable t) {
                        logger.warn("Uncaught exception in ServerLeaveListener!", t);
                    }
                }
            }
        }
    });
}
 
开发者ID:BtoBastian,项目名称:Javacord,代码行数:24,代码来源:GuildDeleteHandler.java


示例6: handle

import de.btobastian.javacord.entities.Server; //导入依赖的package包/类
@Override
public void handle(JSONObject packet) {
    String guildId = packet.getString("guild_id");
    JSONObject roleJson = packet.getJSONObject("role");

    Server server = api.getServerById(guildId);
    final Role role = new ImplRole(roleJson, (ImplServer) server, api);

    listenerExecutorService.submit(new Runnable() {
        @Override
        public void run() {
            List<RoleCreateListener> listeners = api.getListeners(RoleCreateListener.class);
            synchronized (listeners) {
                for (RoleCreateListener listener : listeners) {
                    try {
                        listener.onRoleCreate(api, role);
                    } catch (Throwable t) {
                        logger.warn("Uncaught exception in RoleCreateListener!", t);
                    }
                }
            }
        }
    });
}
 
开发者ID:BtoBastian,项目名称:Javacord,代码行数:25,代码来源:GuildRoleCreateHandler.java


示例7: handle

import de.btobastian.javacord.entities.Server; //导入依赖的package包/类
@Override
public void handle(JSONObject packet) {
    final Server server = api.getServerById(packet.getString("guild_id"));
    final User user = api.getOrCreateUser(packet.getJSONObject("user"));
    if (server != null) {
        ((ImplServer) server).addMember(user);
        ((ImplServer) server).incrementMemberCount();
        listenerExecutorService.submit(new Runnable() {
            @Override
            public void run() {
                List<ServerMemberAddListener> listeners = api.getListeners(ServerMemberAddListener.class);
                synchronized (listeners) {
                    for (ServerMemberAddListener listener : listeners) {
                        try {
                            listener.onServerMemberAdd(api, user, server);
                        } catch (Throwable t) {
                            logger.warn("Uncaught exception in ServerMemberAddListener!", t);
                        }
                    }
                }
            }
        });
    }
}
 
开发者ID:BtoBastian,项目名称:Javacord,代码行数:25,代码来源:GuildMemberAddHandler.java


示例8: handle

import de.btobastian.javacord.entities.Server; //导入依赖的package包/类
@Override
public void handle(JSONObject packet) {
    final Server server = api.getServerById(packet.getString("guild_id"));
    final User user = api.getOrCreateUser(packet.getJSONObject("user"));
    if (server != null) {
        listenerExecutorService.submit(new Runnable() {
            @Override
            public void run() {
                List<ServerMemberBanListener> listeners = api.getListeners(ServerMemberBanListener.class);
                synchronized (listeners) {
                    for (ServerMemberBanListener listener : listeners) {
                        try {
                            listener.onServerMemberBan(api, user, server);
                        } catch (Throwable t) {
                            logger.warn("Uncaught exception in ServerMemberBanListener!", t);
                        }
                    }
                }
            }
        });
    }
}
 
开发者ID:BtoBastian,项目名称:Javacord,代码行数:23,代码来源:GuildBanAddHandler.java


示例9: handle

import de.btobastian.javacord.entities.Server; //导入依赖的package包/类
@Override
public void handle(JSONObject packet) {
    final Server server = api.getServerById(packet.getString("guild_id"));
    final User user = api.getOrCreateUser(packet.getJSONObject("user"));
    if (server != null) {
        ((ImplServer) server).removeMember(user);
        ((ImplServer) server).decrementMemberCount();
        listenerExecutorService.submit(new Runnable() {
            @Override
            public void run() {
                List<ServerMemberRemoveListener> listeners = api.getListeners(ServerMemberRemoveListener.class);
                synchronized (listeners) {
                    for (ServerMemberRemoveListener listener : listeners) {
                        try {
                            listener.onServerMemberRemove(api, user, server);
                        } catch (Throwable t) {
                            logger.warn("Uncaught exception in ServerMemberRemoveListener!", t);
                        }
                    }
                }
            }
        });
    }
}
 
开发者ID:BtoBastian,项目名称:Javacord,代码行数:25,代码来源:GuildMemberRemoveHandler.java


示例10: handle

import de.btobastian.javacord.entities.Server; //导入依赖的package包/类
@Override
public void handle(JSONObject packet) {
    final Server server = api.getServerById(packet.getString("guild_id"));
    final User user = api.getOrCreateUser(packet.getJSONObject("user"));
    if (server != null) {
        ((ImplServer) server).removeMember(user);
        listenerExecutorService.submit(new Runnable() {
            @Override
            public void run() {
                List<ServerMemberUnbanListener> listeners = api.getListeners(ServerMemberUnbanListener.class);
                synchronized (listeners) {
                    for (ServerMemberUnbanListener listener : listeners) {
                        try {
                            listener.onServerMemberUnban(api, user.getId(), server);
                        } catch (Throwable t) {
                            logger.warn("Uncaught exception in ServerMemberUnbanListener!", t);
                        }
                    }
                }
            }
        });
    }
}
 
开发者ID:BtoBastian,项目名称:Javacord,代码行数:24,代码来源:GuildBanRemoveHandler.java


示例11: registerChannels

import de.btobastian.javacord.entities.Server; //导入依赖的package包/类
public void registerChannels() {
    Server server = getServer();
    Collection<ChatChannel> channels = module.getChatModule().getChatChannels();
    for (ChatChannel channel : channels) {
        String name = channel.getChannelName();
        // TODO: Find a way to work around the JDK8 limitation with JavaCord 3.0 not being able to support categories.
        if (name.toLowerCase().contains("faction")) {
            continue;
        }
        // Only register public channels.
        if (!channel.isPublicChannel()) {
            continue;
        }
        String ascii = toAsciiString("channel_" + name);
        Channel dChannel = getChannel(ascii);
        if (dChannel == null) {
            dChannel = createChannelIfNotExists(ascii);
        }
        listPublicChannels.add(dChannel);
    }
}
 
开发者ID:JabJabJab,项目名称:Sledgehammer,代码行数:22,代码来源:DiscordBot.java


示例12: hasRole

import de.btobastian.javacord.entities.Server; //导入依赖的package包/类
/**
 *
 * @param user User to check
 * @param server Server to check against
 * @param roleName Role name
 * @param caseSensitive Case Sensitive
 * @return True or False
 */
public boolean hasRole(User user, Server server, String roleName, boolean caseSensitive){
	if (!caseSensitive) {
		for (Role r : user.getRoles(server)) {
			if (r.getName().equalsIgnoreCase(roleName)) {
				return true;
			}
		}
		return false;
	}else{
		return hasRole(user, server, roleName);
	}
}
 
开发者ID:RealGatt,项目名称:JavacordCommander,代码行数:21,代码来源:JavacordCommander.java


示例13: handle

import de.btobastian.javacord.entities.Server; //导入依赖的package包/类
@Override
public void handle(JSONObject packet) {
    Channel channelTemp = null;
    String channelId = packet.getString("channel_id");
    Iterator<Server> serverIterator = api.getServers().iterator();
    while (serverIterator.hasNext()) {
        channelTemp = serverIterator.next().getChannelById(channelId);
        if (channelTemp != null) {
            break;
        }
    }
    final Channel channel = channelTemp;

    String userId = packet.getString("user_id");
    final User user;
    try {
        user = api.getUserById(userId).get();
    } catch (InterruptedException | ExecutionException e) {
        return;
    }
    listenerExecutorService.submit(new Runnable() {
        @Override
        public void run() {
            List<TypingStartListener> listeners = api.getListeners(TypingStartListener.class);
            synchronized (listeners) {
                for (TypingStartListener listener : listeners) {
                    try {
                        listener.onTypingStart(api, user, channel);
                    } catch (Throwable t) {
                        logger.warn("Uncaught exception in TypingStartListener!", t);
                    }
                }
            }
        }
    });
}
 
开发者ID:BtoBastian,项目名称:Javacord,代码行数:37,代码来源:TypingStartHandler.java


示例14: handle

import de.btobastian.javacord.entities.Server; //导入依赖的package包/类
@Override
public void handle(JSONObject packet) {
    String guildId = packet.getString("guild_id");
    String roleId = packet.getString("role_id");

    Server server = api.getServerById(guildId);
    final Role role = server.getRoleById(roleId);

    if (role == null) {
        return;
    }

    ((ImplServer) server).removeRole(role);

    listenerExecutorService.submit(new Runnable() {
        @Override
        public void run() {
            List<RoleDeleteListener> listeners = api.getListeners(RoleDeleteListener.class);
            synchronized (listeners) {
                for (RoleDeleteListener listener : listeners) {
                    try {
                        listener.onRoleDelete(api, role);
                    } catch (Throwable t) {
                        logger.warn("Uncaught exception in RoleDeleteListener!", t);
                    }
                }
            }
        }
    });
}
 
开发者ID:BtoBastian,项目名称:Javacord,代码行数:31,代码来源:GuildRoleDeleteHandler.java


示例15: handle

import de.btobastian.javacord.entities.Server; //导入依赖的package包/类
@Override
public void handle(JSONObject packet) {
    if (packet.has("unavailable") && packet.getBoolean("unavailable")) {
        return;
    }
    String id = packet.getString("id");
    if (api.getUnavailableServers().contains(id)) {
        api.getUnavailableServers().remove(id);
        new ImplServer(packet, api);
        return;
    }
    if (api.getServerById(id) != null) {
        // TODO update information
        return;
    }
    final Server server = new ImplServer(packet, api);
    listenerExecutorService.submit(new Runnable() {
        @Override
        public void run() {
            List<ServerJoinListener> listeners = api.getListeners(ServerJoinListener.class);
            synchronized (listeners) {
                for (ServerJoinListener listener : listeners) {
                    try {
                        listener.onServerJoin(api, server);
                    } catch (Throwable t) {
                        logger.warn("Uncaught exception in ServerJoinListener!", t);
                    }
                }
            }
        }
    });
    api.getThreadPool().getExecutorService().submit(new Runnable() {
        @Override
        public void run() {
            // can cause a deadlock if someone blocks a listener
            // with the #createServer or #acceptInvite method + #get
            api.getInternalServerJoinListener().onServerJoin(api, server);
        }
    });
}
 
开发者ID:BtoBastian,项目名称:Javacord,代码行数:41,代码来源:GuildCreateHandler.java


示例16: handle

import de.btobastian.javacord.entities.Server; //导入依赖的package包/类
@Override
public void handle(JSONObject packet) {
    final Server server = api.getServerById(packet.getString("guild_id"));
    if (server != null) {
        ((ImplServer) server).addMembers(packet.getJSONArray("members"));
    }
}
 
开发者ID:BtoBastian,项目名称:Javacord,代码行数:8,代码来源:GuildMembersChunkHandler.java


示例17: findReceiver

import de.btobastian.javacord.entities.Server; //导入依赖的package包/类
/**
 * Tries to find the message receiver based on its channel id.
 *
 * @param channelId The channel id of the receiver.
 * @return The receiver with the given id.
 */
private MessageReceiver findReceiver(String channelId) {
    for (Server server : api.getServers()) {
        if (server.getChannelById(channelId) != null) {
            return server.getChannelById(channelId);
        }
    }
    for (User user : api.getUsers()) {
        if (channelId.equals(((ImplUser) user).getUserChannelId())) {
            return user;
        }
    }
    return null;
}
 
开发者ID:BtoBastian,项目名称:Javacord,代码行数:20,代码来源:ImplMessage.java


示例18: getRoles

import de.btobastian.javacord.entities.Server; //导入依赖的package包/类
@Override
public Collection<Role> getRoles(Server server) {
    Collection<Role> userRoles = new ArrayList<>();
    Iterator<Role> rolesIterator = server.getRoles().iterator();
    while (rolesIterator.hasNext()) {
        Role role = rolesIterator.next();
        if (role.getUsers().contains(this)) {
            userRoles.add(role);
        }
    }
    return userRoles;
}
 
开发者ID:BtoBastian,项目名称:Javacord,代码行数:13,代码来源:ImplUser.java


示例19: discoverChannels

import de.btobastian.javacord.entities.Server; //导入依赖的package包/类
public void discoverChannels() {
    String channelConsole = module.getConsoleChannelName();
    for (Server server : api.getServers()) {
        for (Channel channel : server.getChannels()) {
            if (channel.getName().equalsIgnoreCase(channelConsole)) {
                this.channelConsole = channel;
                return;
            }
        }
    }
}
 
开发者ID:JabJabJab,项目名称:Sledgehammer,代码行数:12,代码来源:DiscordBot.java


示例20: getUserByName

import de.btobastian.javacord.entities.Server; //导入依赖的package包/类
/**
 * @param name   The name to search the server for valid a User
 * @param server The server to search through Users
 * @return The User, if any, that matches the name supplied
 */
static Optional<User> getUserByName(String name, Server server) {
    for (User user : server.getMembers()) {
        if (user.getName().equalsIgnoreCase(name) || (user.getNickname(server) != null && user.getNickname(server).equalsIgnoreCase(name))) {
            return Optional.of(user);
        }
    }
    return Optional.empty();
}
 
开发者ID:nguyenquyhy,项目名称:DiscordBridge,代码行数:14,代码来源:DiscordUtil.java



注:本文中的de.btobastian.javacord.entities.Server类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java HtmlElement类代码示例发布时间:2022-05-22
下一篇:
Java HttpClient类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap