Search in sources :

Example 1 with BungeePlayer

use of me.anton.sickcore.api.player.bungeePlayer.BungeePlayer in project SickCore by SickMC.

the class MCDiscordCommand method onCMD.

@Subcommand("update")
@Description("Updates your rank on discord")
public void onCMD(CommandSender sender) {
    if (!(sender instanceof ProxiedPlayer)) {
        ConsoleMessages.noPlayerBungee(sender);
        return;
    }
    BungeePlayer player = new BungeePlayer(sender);
    if (!player.api().isVerified()) {
        player.getPlayer().sendMessage(new TextComponent((String) player.api().languageObject("§4You are not verifed!", "§4Du bist nicht verifiziert!")));
        return;
    }
    new RankUpdate(player);
    player.getPlayer().sendMessage(new TextComponent((String) player.api().languageObject("§7Your rank successfully updated!", "§7Dein Rang wurde erfolgreich neu geladen!")));
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) RankUpdate(me.anton.sickcore.modules.discord.modules.ranks.RankUpdate) ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) BungeePlayer(me.anton.sickcore.api.player.bungeePlayer.BungeePlayer) Description(co.aikar.commands.annotation.Description) Subcommand(co.aikar.commands.annotation.Subcommand)

Example 2 with BungeePlayer

use of me.anton.sickcore.api.player.bungeePlayer.BungeePlayer in project SickCore by SickMC.

the class MCDiscordCommand method onCmd.

@Subcommand("verify")
@Description("Verify with discord account")
public void onCmd(CommandSender sender) {
    if (!(sender instanceof ProxiedPlayer)) {
        ConsoleMessages.noPlayerBungee(sender);
        return;
    }
    BungeePlayer player = new BungeePlayer(sender);
    if (player.api().isVerified()) {
        player.getPlayer().sendMessage(new TextComponent((String) player.api().languageObject("§7You are already verified with §6" + DiscordModule.getInstance().getJda().getUserById(player.api().getDiscordID()).getAsTag() + "§7!", "§7Du bist bereits mit §6" + DiscordModule.getInstance().getJda().getUserById(player.api().getDiscordID()).getAsTag() + "§7 verbunden!")));
        return;
    }
    int verifyCode = MathUtils.getRandomNumberInRange(100000, 999999);
    if (VerifyModule.getVerifyModule().getVerifyList().containsValue(verifyCode))
        verifyCode = MathUtils.getRandomNumberInRange(100000, 999999);
    VerifyModule.getVerifyModule().getVerifyList().put(player, verifyCode);
    VerifyModule.getVerifyModule().getVerifyListReturn().put(verifyCode, player);
    BaseComponent en = new TextComponent("§7Your verify code is §6" + verifyCode + "§7!");
    en.setClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, String.valueOf(verifyCode)));
    en.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§7Click to copy the code!").create()));
    BaseComponent de = new TextComponent("§7Dein Verifikationscode ist §6" + verifyCode + "§7!");
    en.setClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, String.valueOf(verifyCode)));
    en.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§7Klicke um den Code zu kopieren!").create()));
    player.getPlayer().sendMessage((BaseComponent) player.api().languageObject(en, de));
    MessageEmbed embed = new EmbedBuilder().setTimestamp(Instant.now()).setTitle("**Verify | SickMC**").setDescription(player.api().getName() + " started verification! \nHis code is " + verifyCode + "!").setFooter("SickMC • Requested by " + player.api().getName()).setColor(Color.ORANGE).build();
    DiscordLogModule.getInstance().log(embed);
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder) MessageEmbed(net.dv8tion.jda.api.entities.MessageEmbed) BungeePlayer(me.anton.sickcore.api.player.bungeePlayer.BungeePlayer) Description(co.aikar.commands.annotation.Description) Subcommand(co.aikar.commands.annotation.Subcommand)

Example 3 with BungeePlayer

use of me.anton.sickcore.api.player.bungeePlayer.BungeePlayer in project SickCore by SickMC.

the class VerifyCommand method execute.

@Override
public void execute(User user, DiscordPlayer player, InteractionHook hook, SlashCommandEvent event) {
    DiscordModule module = DiscordModule.getInstance();
    VerifyModule verifyModule = VerifyModule.getVerifyModule();
    int verifyID = (int) event.getOption("code").getAsLong();
    if (DiscordAPIPlayerAdapter.isVerified(user)) {
        hook.sendMessageEmbeds(getAlreadyVerified(user)).setEphemeral(false).queue();
        return;
    }
    if (!verifyModule.getVerifyList().containsValue(verifyID)) {
        hook.sendMessageEmbeds(getWrongCodeEmbed(user)).setEphemeral(true).queue();
        return;
    }
    BungeePlayer bungeeplayer = verifyModule.getVerifyListReturn().get(verifyID);
    verify(bungeeplayer, user.getId());
    verifyModule.getVerifyListReturn().remove(verifyID, bungeeplayer);
    verifyModule.getVerifyList().remove(bungeeplayer, verifyID);
    sendLog(user, bungeeplayer);
    bungeeplayer.getPlayer().sendMessage(new TextComponent((String) bungeeplayer.api().languageObject("§7Your account is now linked with §6" + event.getMember().getUser().getAsTag() + "§7!", "§7Dein Account ist nun mit §6" + event.getMember().getUser().getAsTag() + "§7 verbunden!")));
    hook.sendMessageEmbeds(getVerified(user)).queue();
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) BungeePlayer(me.anton.sickcore.api.player.bungeePlayer.BungeePlayer) DiscordModule(me.anton.sickcore.modules.discord.DiscordModule)

Example 4 with BungeePlayer

use of me.anton.sickcore.api.player.bungeePlayer.BungeePlayer in project SickCore by SickMC.

the class LobbyCommand method onCOm.

@Default
@Description("Sends you to lobby")
public void onCOm(CommandSender sender) {
    if (!(sender instanceof ProxiedPlayer)) {
        ConsoleMessages.noPlayerBungee(sender);
        return;
    }
    BungeePlayer player = new BungeePlayer(sender);
    if (player.api().cloud().cloudAPI().getConnectedServer().isLobby()) {
        player.sendMessage(LanguagePath.PROXY_STAFF_COMMAND_LOBBY_ALREADY);
        return;
    }
    player.api().cloud().cloudAPI().sendToLobby();
    player.sendMessage(LanguagePath.PROXY_STAFF_COMMAND_LOBBY_SUCCESS);
}
Also used : ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) BungeePlayer(me.anton.sickcore.api.player.bungeePlayer.BungeePlayer) Description(co.aikar.commands.annotation.Description) Default(co.aikar.commands.annotation.Default)

Example 5 with BungeePlayer

use of me.anton.sickcore.api.player.bungeePlayer.BungeePlayer in project SickCore by SickMC.

the class PlaytimeCommand method onCMDD.

@Default
@Syntax("<Player>")
@Description("Shows the playtime of the player")
public void onCMDD(CommandSender sender, @Optional String targetRaw) {
    if (!(sender instanceof ProxiedPlayer)) {
        ConsoleMessages.noPlayerBungee(sender);
        return;
    }
    BungeePlayer player = new BungeePlayer(sender);
    if (targetRaw != null) {
        IOfflineCloudPlayer cloudPlayer = CloudAPI.getInstance().getCloudPlayerManager().getOfflineCloudPlayer(targetRaw).getBlockingOrNull();
        if (cloudPlayer == null) {
            player.getPlayer().sendMessage(new TextComponent("§4This player cannot be found!"));
            return;
        }
        player.sendMessage(player.api().languageString(LanguagePath.PROXY_COMMAND_PLAYTIME_TIME).replace(new Replacable("%playtime%", TimeUtils.formatMillis(cloudPlayer.getOnlineTime()))));
        return;
    }
    player.sendMessage(player.api().languageString(LanguagePath.PROXY_COMMAND_PLAYTIME_TIME).replace(new Replacable("%playtime%", TimeUtils.formatMillis(player.api().cloud().cloudAPI().getOnlineTime()))));
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) BungeePlayer(me.anton.sickcore.api.player.bungeePlayer.BungeePlayer) Replacable(me.anton.sickcore.api.utils.common.Replacable) IOfflineCloudPlayer(eu.thesimplecloud.api.player.IOfflineCloudPlayer)

Aggregations

BungeePlayer (me.anton.sickcore.api.player.bungeePlayer.BungeePlayer)9 ProxiedPlayer (net.md_5.bungee.api.connection.ProxiedPlayer)7 TextComponent (net.md_5.bungee.api.chat.TextComponent)6 Description (co.aikar.commands.annotation.Description)4 Subcommand (co.aikar.commands.annotation.Subcommand)3 CommandAlias (co.aikar.commands.annotation.CommandAlias)1 Default (co.aikar.commands.annotation.Default)1 LiteralArgumentBuilder (com.mojang.brigadier.builder.LiteralArgumentBuilder)1 LiteralCommandNode (com.mojang.brigadier.tree.LiteralCommandNode)1 BrigadierCommand (com.velocitypowered.api.command.BrigadierCommand)1 CommandSource (com.velocitypowered.api.command.CommandSource)1 Player (com.velocitypowered.api.proxy.Player)1 ServerSelectorType (de.dytanic.cloudnet.ext.bridge.player.executor.ServerSelectorType)1 IOfflineCloudPlayer (eu.thesimplecloud.api.player.IOfflineCloudPlayer)1 DatabaseModel (me.anton.sickcore.api.database.DatabaseModel)1 LanguagePath (me.anton.sickcore.api.player.apiPlayer.language.LanguagePath)1 Replacable (me.anton.sickcore.api.utils.common.Replacable)1 DiscordModule (me.anton.sickcore.modules.discord.DiscordModule)1 RankUpdate (me.anton.sickcore.modules.discord.modules.ranks.RankUpdate)1 Staff (me.anton.sickcore.modules.staff.Staff)1