當前位置: 首頁>>代碼示例>>Java>>正文


Java Game類代碼示例

本文整理匯總了Java中net.dv8tion.jda.core.entities.Game的典型用法代碼示例。如果您正苦於以下問題:Java Game類的具體用法?Java Game怎麽用?Java Game使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Game類屬於net.dv8tion.jda.core.entities包,在下文中一共展示了Game類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import net.dv8tion.jda.core.entities.Game; //導入依賴的package包/類
public static void main(String[] args) throws IOException {
    //Code by ZekroTJA(github.com/ZekroTJA)
    StartArgumentHandler.args = args;
    //MY CODE
    builder = new JDABuilder(AccountType.BOT)
            .setToken(SECRETS.TOKEN)
            .setAudioEnabled(true)
            .setAutoReconnect(true)
            .setStatus(STATICS.STATUS)
            .setGame(Game.of(STATICS.CUSTOM_MESSAGE + " | _help | coded by Lee", "http://twitch.tv/lordleeyt"))
            ;

    initializeListeners();
    initializeCommands();
    SQL.connect();
    LVL.connect();


    try {
        builder.buildBlocking();
    } catch (InterruptedException | RateLimitedException | LoginException e) {
        e.printStackTrace();
    }

}
 
開發者ID:LeeDJD,項目名稱:Amme,代碼行數:26,代碼來源:Main.java

示例2: start

import net.dv8tion.jda.core.entities.Game; //導入依賴的package包/類
public void start() throws RateLimitedException, InterruptedException, LoginException {
    this.discordAPI = new JDABuilder(AccountType.BOT)
                              .setToken(settings.getToken())
                              .setGame(new GameImpl(settings.getGame(), settings.getGameUrl(), settings.isTwitch() ? Game.GameType.TWITCH : Game.GameType.DEFAULT))
                              .addListener(new EventCaller(this))
                              .setAutoReconnect(true)
                              .setAudioEnabled(true)
                              .setBulkDeleteSplittingEnabled(false)
                              .buildBlocking();
    if (settings.getRedis().isEnabled()) {
        redisConnection.start();
        keepDataThread.start();
    }
    initCommands();
    initListeners();
}
 
開發者ID:kacperduras,項目名稱:Charrizard,代碼行數:17,代碼來源:Charrizard.java

示例3: updateStatus

import net.dv8tion.jda.core.entities.Game; //導入依賴的package包/類
void updateStatus() {
	Runnable changeStatus = () -> {
		AtomicInteger users = new AtomicInteger(0), guilds = new AtomicInteger(0);
		if (MantaroRPG.getInstance() != null) {
			Arrays.stream(MantaroRPG.getInstance().getShards()).map(MantaroShard::getJDA).forEach(jda -> {
				users.addAndGet(jda.getUsers().size());
				guilds.addAndGet(jda.getGuilds().size());
			});
		}
		String newStatus = random(SPLASHES.get(), RANDOM)
			.replace("%ramgb%", String.valueOf(((long) (Runtime.getRuntime().maxMemory() * 1.2D)) >> 30L))
			.replace("%usercount%", users.toString())
			.replace("%guildcount%", guilds.toString())
			.replace("%shardcount%", String.valueOf(getTotalShards()))
			.replace("%prettyusercount%", pretty(users.get()))
			.replace("%prettyguildcount%", pretty(guilds.get()));

		getJDA().getPresence().setGame(Game.of(config().get().prefix + "help | " + newStatus + " | [" + getId() + "]"));
		log.debug("Changed status to: " + newStatus);
	};

	changeStatus.run();
	Async.task("Splash Thread", changeStatus, 600);
}
 
開發者ID:Mantaro,項目名稱:MantaroRPG,代碼行數:25,代碼來源:MantaroShard.java

示例4: execute

import net.dv8tion.jda.core.entities.Game; //導入依賴的package包/類
@Override
protected Message execute(CommandManager.ParsedCommandInvocation parsedCommandInvocation, UserPermissions userPermissions) {
    Configuration configuration = RubiconBot.getConfiguration();
    if(!configuration.has(configKey)) {
        configuration.set(configKey, "0");
    }
    if(parsedCommandInvocation.args.length == 0) {
        configuration.set(configKey, "0");
        return null;
    }
    String message = "";
    for (String s : parsedCommandInvocation.args)
        message += s + " ";

    RubiconBot.getConfiguration().set(configKey, message);
    parsedCommandInvocation.getMessage().getJDA().getPresence().setGame(Game.playing(message));

    return new MessageBuilder().setEmbed(EmbedUtil.success("Status set!", "Successfully set the playing status!").build()).build();
}
 
開發者ID:Rubicon-Bot,項目名稱:Rubicon,代碼行數:20,代碼來源:CommandPlay.java

示例5: fetch

import net.dv8tion.jda.core.entities.Game; //導入依賴的package包/類
@SuppressWarnings("UnusedReturnValue")
private static String fetch() {
    try {
        info = Unirest.get("https://gensokyoradio.net/xml").asString().getBody();

        JSONObject data = XML.toJSONObject(GensokyoInfoAgent.getInfo()).getJSONObject("GENSOKYORADIODATA");

        String newSong = data.getJSONObject("SONGINFO").getString("TITLE");

        if (!newSong.equals(lastSong)) {
            List<FredBoat> shards = FredBoat.getShards();
            for(FredBoat shard : shards) {
                shard.getJda().getPresence().setGame(Game.of(newSong));
            }

            log.info("Now playing " + newSong);
        }

        lastSong = data.getJSONObject("SONGINFO").getString("TITLE");

        return info;
    } catch (UnirestException e) {
        throw new RuntimeException(e);
    }
}
 
開發者ID:Frederikam,項目名稱:GensokyoBot,代碼行數:26,代碼來源:GensokyoInfoAgent.java

示例6: main

import net.dv8tion.jda.core.entities.Game; //導入依賴的package包/類
public static void main(final String[] args) throws Exception {
    Thread.currentThread().setName("JukeBot-Main");

    ConfigurationFactory.setConfigurationFactory(new Log4JConfig());
    LOG = LogManager.getLogger("JukeBot");

    playerManager = new DefaultAudioPlayerManager();
    defaultPrefix = Database.getPropertyFromConfig("prefix");

    String colour = Database.getPropertyFromConfig("color");
    if (colour.equalsIgnoreCase("")) {
        LOG.error("Missing property 'color' in the database.");
        return;
    }

    embedColour = Color.decode(colour);

    playerManager.setPlayerCleanupThreshold(30000);
    playerManager.getConfiguration().setResamplingQuality(AudioConfiguration.ResamplingQuality.LOW);
    playerManager.getConfiguration().setOpusEncodingQuality(9);
    YoutubeAudioSourceManager yt = new YoutubeAudioSourceManager();
    yt.setPlaylistPageCount(Integer.MAX_VALUE);
    playerManager.registerSourceManager(yt);
    AudioSourceManagers.registerRemoteSources(playerManager);

    printBanner();

    shardManager = new DefaultShardManagerBuilder()
            .setToken(Database.getPropertyFromConfig("token"))
            .setShardsTotal(-1)
            .addEventListeners(new EventListener(), waiter)
            .setAudioSendFactory(new NativeAudioSendFactory())
            .setGame(Game.of(Game.GameType.LISTENING, defaultPrefix + "help | jukebot.xyz"))
            .build();
}
 
開發者ID:Devoxin,項目名稱:JukeBot,代碼行數:36,代碼來源:JukeBot.java

示例7: onCommand

import net.dv8tion.jda.core.entities.Game; //導入依賴的package包/類
@Override
public boolean onCommand(Message message, String[] args) {
    if (args.length == 0) {
        return false;
    }

    Game game = parseGame(args);
    message.getJDA().getPresence().setGame(game);

    MessageFactory.makeSuccess(message, "Changed status to **:type :status**")
        .set("type", getTypeAsString(game.getType()))
        .set("status", game.getName())
        .queue();

    return true;
}
 
開發者ID:avaire,項目名稱:avaire,代碼行數:17,代碼來源:SetStatusCommand.java

示例8: getGameFromType

import net.dv8tion.jda.core.entities.Game; //導入依賴的package包/類
private Game getGameFromType(String status, AvaireShard shard) {
    Game game = Game.playing(status);
    if (status.contains(":")) {
        String[] split = status.split(":");
        status = String.join(":", Arrays.copyOfRange(split, 1, split.length));
        switch (split[0].toLowerCase()) {
            case "listen":
            case "listening":
                return Game.listening(formatGame(status, shard));

            case "watch":
            case "watching":
                return Game.watching(formatGame(status, shard));

            case "play":
            case "playing":
                return Game.playing(formatGame(status, shard));

            case "stream":
            case "streaming":
                return Game.streaming(formatGame(status, shard), "https://www.twitch.tv/senither");
        }
    }
    return game;
}
 
開發者ID:avaire,項目名稱:avaire,代碼行數:26,代碼來源:ChangeGameJob.java

示例9: start

import net.dv8tion.jda.core.entities.Game; //導入依賴的package包/類
public void start() throws LoginException, InterruptedException, RateLimitedException {
    running = true;

    // init logger
    AnsiConsole.systemInstall();
    log = Logger.getLogger("Kyoko");
    log.setUseParentHandlers(false);
    ColoredFormatter formatter = new ColoredFormatter();
    ConsoleHandler handler = new ConsoleHandler();
    handler.setFormatter(formatter);
    log.addHandler(handler);

    log.info("Kyoko v" + Constants.VERSION + " is starting...");

    i18n.loadMessages();

    JDABuilder builder = new JDABuilder(AccountType.BOT);
    if (settings.getToken() != null) {
        if (settings.getToken().equalsIgnoreCase("Change me")) {
            System.out.println("No token specified, please set it in config.json");
            System.exit(1);
        }
        builder.setToken(settings.getToken());
    }

    boolean gameEnabled = false;
    if (settings.getGame() != null && !settings.getGame().isEmpty()) {
        gameEnabled = true;
        builder.setGame(Game.of("booting..."));
    }

    builder.setAutoReconnect(true);
    builder.setBulkDeleteSplittingEnabled(false);
    builder.addEventListener(eventHandler);
    builder.setAudioEnabled(true);
    builder.setStatus(OnlineStatus.IDLE);
    jda = builder.buildBlocking();

    log.info("Invite link: " + "https://discordapp.com/oauth2/authorize?&client_id=" + jda.getSelfUser().getId() + "&scope=bot&permissions=" + Constants.PERMISSIONS);

    if (gameEnabled) {
        Thread t = new Thread(new Kyoko.BlinkThread());
        t.start();
    }

    registerCommands();
}
 
開發者ID:gabixdev,項目名稱:Kyoko,代碼行數:48,代碼來源:Kyoko.java

示例10: PlaystatusHandler

import net.dv8tion.jda.core.entities.Game; //導入依賴的package包/類
public PlaystatusHandler() {
	String json;
	try {
		json = IOUtils.toString(getClass().getResourceAsStream("/Playstatuses.json"), "UTF-8");
	} catch (IOException e) {
		LOG.log(Level.SEVERE, "Cannot load play statuses. Disabling playstatus handler.");
		return;
	}

	this.random = new Random();

	Gson gson = new Gson();
	this.statuses = gson.fromJson(json, PlaystatusFile.class).getData();

	Timer timer = new Timer();
	timer.scheduleAtFixedRate(new TimerTask() {
		@Override
		public void run() {
			Grimoire.getInstance().getDiscord().getPresence().setGame(Game.of(getRandomStatus()));
		}
	}, 0, CHANGE_INTERVAL);
}
 
開發者ID:BeMacized,項目名稱:Grimoire,代碼行數:23,代碼來源:PlaystatusHandler.java

示例11: execute

import net.dv8tion.jda.core.entities.Game; //導入依賴的package包/類
@Override
protected void execute(CommandEvent event)
{
    String[] parts = event.getArgs().split("\\s+", 2);
    if(parts.length<2)
    {
        event.replyError("Please include a twitch username and the name of the game to 'stream'");
        return;
    }
    try
    {
        event.getJDA().getPresence().setGame(Game.streaming(parts[1], "https://twitch.tv/"+parts[0]));
        event.replySuccess("**"+event.getSelfUser().getName()
                +"** is now streaming `"+parts[1]+"`");
    }
    catch(Exception e)
    {
        event.reply(event.getClient().getError()+" The game could not be set!");
    }
}
 
開發者ID:jagrosh,項目名稱:MusicBot,代碼行數:21,代碼來源:SetgameCmd.java

示例12: dispatch

import net.dv8tion.jda.core.entities.Game; //導入依賴的package包/類
@Override
public void dispatch(String[] args, MessageChannel channel, Message msg) {
    if (args.length > 1 && args[0].toLowerCase().matches("(game)|(stream=.+)")) {
        if (args[0].equalsIgnoreCase("game")) {
            UserBot.getInstance().getJda().getPresence()
                    .setGame(Game.of(Arrays.stream(args).skip(1).collect(Collectors.joining(" "))));
            msg.deleteMessage().queue();
        } else {
            Matcher m = GET_STREAM_URL_PATTERN.matcher(args[0]);
            if (m.matches()) {
                if (Game.isValidStreamingUrl(m.group(1))) {
                    UserBot.getInstance().getJda().getPresence()
                            .setGame(Game.of(Arrays.stream(args).skip(1).collect(Collectors.joining(" ")), m.group(1)));
                    msg.deleteMessage().queue();
                } else {
                    UserBot.getInstance().getJda().getPresence()
                            .setGame(Game.of(Arrays.stream(args).skip(1).collect(Collectors.joining(" "))));
                    msg.deleteMessage().queue();
                }
            }
        }
    }
}
 
開發者ID:ArsenArsen,項目名稱:SelfBot,代碼行數:24,代碼來源:Status.java

示例13: onReady

import net.dv8tion.jda.core.entities.Game; //導入依賴的package包/類
@Override
public void onReady(ReadyEvent event)
{
    if(!event.getJDA().getSelfUser().isBot())
    {
        LOG.error("JDA-Utilities does not support CLIENT accounts.");
        event.getJDA().shutdown();
        return;
    }
    textPrefix = prefix.equals(DEFAULT_PREFIX) ? "@"+event.getJDA().getSelfUser().getName()+" " : prefix;
    event.getJDA().getPresence().setStatus(status==null ? OnlineStatus.ONLINE : status);
    if(game!=null)
        event.getJDA().getPresence().setGame("default".equals(game.getName()) ?
                Game.playing("Type "+textPrefix+helpWord) :
                game);
    sendStats(event.getJDA());
}
 
開發者ID:JDA-Applications,項目名稱:JDA-Utilities,代碼行數:18,代碼來源:CommandClientImpl.java

示例14: initJda

import net.dv8tion.jda.core.entities.Game; //導入依賴的package包/類
/**
 * Starts JDA.
 *
 * @return {@code true} if everything went well, {@code false} otherwise.
 */
private boolean initJda() {

    try {
        SimpleLog.Level level = JDAImpl.LOG.getLevel();
        SimpleLog.Level socketLevel = WebSocketClient.LOG.getLevel();
        JDAImpl.LOG.setLevel(SimpleLog.Level.OFF);
        WebSocketClient.LOG.setLevel(SimpleLog.Level.OFF);

        jda = new JDABuilder(AccountType.BOT).setToken(botToken).buildBlocking();
        jda.getPresence().setGame(Game.of("2.0.2"));
        logger.writeFrom("jda", "Successfully connected!");
        logger.writeFrom("jda WebSocket", "Connected to WebSocket!");

        JDAImpl.LOG.setLevel(level);
        WebSocketClient.LOG.setLevel(socketLevel);
    } catch (LoginException | InterruptedException | RateLimitedException e) {
        logger.writeFrom("jda", "Couldn't connect!");
        e.printStackTrace();
        return false;
    }
    return true;
}
 
開發者ID:iSach,項目名稱:Samaritan,代碼行數:28,代碼來源:Samaritan.java

示例15: setPresence

import net.dv8tion.jda.core.entities.Game; //導入依賴的package包/類
@Override
public void setPresence(OnlineStatus status, Game game, boolean idle)
{
    JSONObject gameObj = getGameJson(game);

    Checks.check(status != OnlineStatus.UNKNOWN,
            "Cannot set the presence status to an unknown OnlineStatus!");
    if (status == OnlineStatus.OFFLINE || status == null)
        status = OnlineStatus.INVISIBLE;

    JSONObject object = new JSONObject();

    if (gameObj == null)
        object.put("game", JSONObject.NULL);
    else
        object.put("game", gameObj);
    object.put("afk", idle);
    object.put("status", status.getKey());
    object.put("since", System.currentTimeMillis());
    update(object);
    this.idle = idle;
    this.status = status;
    this.game = gameObj == null ? null : game;
}
 
開發者ID:DV8FromTheWorld,項目名稱:JDA,代碼行數:25,代碼來源:PresenceImpl.java


注:本文中的net.dv8tion.jda.core.entities.Game類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。