Search in sources :

Example 26 with TextComponent

use of net.md_5.bungee.api.chat.TextComponent in project Arcade2 by ShootGame.

the class RestartCountdown method onTick.

@Override
public void onTick(long ticks) {
    Game game = this.plugin.getGames().getCurrentGame();
    if (game == null) {
        return;
    } else if (this.getProgress() > 1) {
        return;
    }
    String message = this.getPrintMessage(this.getRestartMessage());
    BossBar bossBar = this.getBossBar();
    bossBar.setProgress(Percentage.finite(this.getProgress()));
    bossBar.setText(new TextComponent(message));
    for (ArcadePlayer online : this.plugin.getPlayers()) {
        GamePlayer player = online.getGamePlayer();
        if (player != null) {
            bossBar.addPlayer(player, BAR_PRIORITY);
        }
    }
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) ArcadePlayer(pl.themolka.arcade.session.ArcadePlayer) BossBar(pl.themolka.arcade.bossbar.BossBar)

Example 27 with TextComponent

use of net.md_5.bungee.api.chat.TextComponent in project Arcade2 by ShootGame.

the class MatchStartCountdown method onTick.

@Override
public void onTick(long ticks) {
    Game game = this.plugin.getGames().getCurrentGame();
    if (game == null) {
        return;
    } else if (this.getProgress() > 1) {
        return;
    }
    String message = this.getPrintMessage(this.getStartMessage());
    BossBar bossBar = this.getBossBar();
    bossBar.setProgress(Percentage.finite(this.getProgress()));
    bossBar.setText(new TextComponent(message));
    for (ArcadePlayer online : this.plugin.getPlayers()) {
        GamePlayer player = online.getGamePlayer();
        if (player != null) {
            bossBar.addPlayer(player, BAR_PRIORITY);
        }
    }
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) Game(pl.themolka.arcade.game.Game) ArcadePlayer(pl.themolka.arcade.session.ArcadePlayer) GamePlayer(pl.themolka.arcade.game.GamePlayer) BossBar(pl.themolka.arcade.bossbar.BossBar)

Example 28 with TextComponent

use of net.md_5.bungee.api.chat.TextComponent in project SkinsRestorerX by DoNotSpamPls.

the class SkinsRestorer method checkVersion.

private String checkVersion(CommandSender console) {
    try {
        HttpsURLConnection con = (HttpsURLConnection) new URL("https://api.spigotmc.org/legacy/update.php?resource=2124").openConnection();
        con.setDoOutput(true);
        con.setRequestMethod("GET");
        String version = new BufferedReader(new InputStreamReader(con.getInputStream())).readLine();
        if (version.length() <= 13)
            return version;
    } catch (Exception ex) {
        ex.printStackTrace();
        console.sendMessage(new TextComponent("§e[§2SkinsRestorer§e] §cFailed to check for an update on Spigot."));
    }
    return getVersion();
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) InputStreamReader(java.io.InputStreamReader) BufferedReader(java.io.BufferedReader) HttpsURLConnection(javax.net.ssl.HttpsURLConnection) URL(java.net.URL) SkinRequestException(skinsrestorer.shared.utils.MojangAPI.SkinRequestException)

Example 29 with TextComponent

use of net.md_5.bungee.api.chat.TextComponent in project SkinsRestorerX by DoNotSpamPls.

the class AdminCommands method execute.

@SuppressWarnings("deprecation")
public void execute(final CommandSender sender, final String[] args) {
    if (sender.hasPermission("skinsrestorer.cmds")) {
        if (args.length == 1 && args[0].equalsIgnoreCase("reload")) {
            Locale.load();
            Config.load(SkinsRestorer.getInstance().getResourceAsStream("config.yml"));
            sender.sendMessage(new TextComponent(Locale.RELOAD));
        } else if (args.length == 2 && args[0].equalsIgnoreCase("drop")) {
            StringBuilder sb = new StringBuilder();
            SkinStorage.removeSkinData(sb.toString());
            sender.sendMessage(Locale.SKIN_DATA_DROPPED.replace("%player", sb.toString()));
        } else if (args.length > 2 && args[0].equalsIgnoreCase("set")) {
            final String skin = args[2];
            ProxiedPlayer player = ProxyServer.getInstance().getPlayer(args[1]);
            if (player == null)
                for (ProxiedPlayer pl : ProxyServer.getInstance().getPlayers()) if (pl.getName().startsWith(args[1])) {
                    player = pl;
                    break;
                }
            if (player == null) {
                sender.sendMessage(Locale.NOT_ONLINE);
                return;
            }
            final ProxiedPlayer p = player;
            ProxyServer.getInstance().getScheduler().runAsync(SkinsRestorer.getInstance(), () -> {
                try {
                    MojangAPI.getUUID(skin);
                    SkinStorage.setPlayerSkin(p.getName(), skin);
                    SkinApplier.applySkin(p);
                    sender.sendMessage(Locale.SKIN_CHANGE_SUCCESS);
                } catch (MojangAPI.SkinRequestException e) {
                    sender.sendMessage(e.getReason());
                }
            });
        } else if (args.length == 1 && args[0].equalsIgnoreCase("config")) {
            sender.sendMessage("§e[§2SkinsRestorer§e] §2/sr config has been removed from SkinsRestorer. Farewell!");
        } else if (args.length > 0 && args[0].equalsIgnoreCase("props")) {
            ProxiedPlayer p;
            if (args.length == 1) {
                if (!(sender instanceof ProxiedPlayer)) {
                    sender.sendMessage(Locale.NOT_PLAYER);
                }
                p = (ProxiedPlayer) sender;
            } else {
                StringBuilder name = new StringBuilder();
                for (int i = 1; i < args.length; i++) if (args.length == 2)
                    name.append(args[i]);
                else if (i + 1 == args.length)
                    name.append(args[i]);
                else
                    name.append(args[i]).append(" ");
                p = ProxyServer.getInstance().getPlayer(name.toString());
                if (p == null) {
                    sender.sendMessage(Locale.NOT_ONLINE);
                    return;
                }
            }
            InitialHandler h = (InitialHandler) p.getPendingConnection();
            LoginResult.Property prop = h.getLoginProfile().getProperties()[0];
            if (prop == null) {
                sender.sendMessage(Locale.NO_SKIN_DATA);
                return;
            }
            CommandSender cons = ProxyServer.getInstance().getConsole();
            cons.sendMessage("\n§aName: §8" + prop.getName());
            cons.sendMessage("\n§aValue : §8" + prop.getValue());
            cons.sendMessage("\n§aSignature : §8" + prop.getSignature());
            byte[] decoded = Base64.getDecoder().decode(prop.getValue());
            cons.sendMessage("\n§aValue Decoded: §e" + Arrays.toString(decoded));
            sender.sendMessage("\n§e" + Arrays.toString(decoded));
            sender.sendMessage("§cMore info in console!");
        } else {
            if (!Locale.SR_LINE.isEmpty())
                sender.sendMessage(Locale.SR_LINE);
            sender.sendMessage(Locale.HELP_ADMIN.replace("%ver%", SkinsRestorer.getInstance().getVersion()));
            if (!Locale.SR_LINE.isEmpty())
                sender.sendMessage(Locale.SR_LINE);
        }
    } else {
        sender.sendMessage(Locale.PLAYER_HAS_NO_PERMISSION);
    }
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) LoginResult(net.md_5.bungee.connection.LoginResult) MojangAPI(skinsrestorer.shared.utils.MojangAPI) CommandSender(net.md_5.bungee.api.CommandSender) InitialHandler(net.md_5.bungee.connection.InitialHandler)

Example 30 with TextComponent

use of net.md_5.bungee.api.chat.TextComponent in project FireAPI by FireBlade-Serv.

the class Events method onConnection.

@EventHandler
public void onConnection(PreLoginEvent e) {
    String name = e.getConnection().getName();
    String ip = e.getConnection().getAddress().getAddress().getHostAddress();
    this.instance.getBungeePlugin().getLogger().info("Tentative de connection de " + name + " avec l'adresse IP : " + ip + ".");
    try {
        this.instance.getWhitelistSystem().setDefault(name, ip);
        this.instance.getWhitelistSystem().loadConfiguration();
    } catch (IOException e2) {
        this.instance.getChatUtils().sendMessageToGroup(this.instance.getWhitelistSystem().getPrefix() + "§c Une erreur critique est survenue ! {name = " + name + ", " + e2.getMessage() + "}", VersionType.BUNGEECORD_VERSION, Rank.MODÉRATEUR);
        e.setCancelReason(new TextComponent("§cUne erreur critique est survenue ! Veuillez contacter Glowstoner ! (SpamBot ?)"));
        e.setCancelled(true);
        return;
    }
    if (this.instance.getWhitelistSystem().isEnable() == false) {
        return;
    }
    File file = new File(this.instance.getBungeePlugin().getDataFolder(), "whitelist.yml");
    Configuration config;
    try {
        config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file);
        boolean accepted = config.getBoolean("players." + name + ".accepted");
        if (config.getString("players." + name + ".ip").equals(ip) && accepted == true) {
            return;
        }
        e.setCancelReason(new TextComponent("§cLe serveur est en maintenance !\n§9Discord : https://discordapp.com/invite/H7acUcX"));
        e.setCancelled(true);
    } catch (IOException e1) {
        this.instance.getChatUtils().sendMessageToGroup(this.instance.getWhitelistSystem().getPrefix() + "§c Une erreur critique est survenue ! {name = " + name + ", " + e1.getMessage() + "}", VersionType.BUNGEECORD_VERSION, Rank.MODÉRATEUR);
    }
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) Configuration(net.md_5.bungee.config.Configuration) YamlConfiguration(net.md_5.bungee.config.YamlConfiguration) IOException(java.io.IOException) File(java.io.File) EventHandler(net.md_5.bungee.event.EventHandler)

Aggregations

TextComponent (net.md_5.bungee.api.chat.TextComponent)50 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)12 ProxiedPlayer (net.md_5.bungee.api.connection.ProxiedPlayer)12 Player (org.bukkit.entity.Player)12 ISoliniaPlayer (com.solinia.solinia.Interfaces.ISoliniaPlayer)11 ClickEvent (net.md_5.bungee.api.chat.ClickEvent)11 ComponentBuilder (net.md_5.bungee.api.chat.ComponentBuilder)9 HoverEvent (net.md_5.bungee.api.chat.HoverEvent)9 IOException (java.io.IOException)6 Configuration (net.md_5.bungee.config.Configuration)6 YamlConfiguration (net.md_5.bungee.config.YamlConfiguration)6 ISoliniaItem (com.solinia.solinia.Interfaces.ISoliniaItem)5 ArrayList (java.util.ArrayList)5 ISoliniaLivingEntity (com.solinia.solinia.Interfaces.ISoliniaLivingEntity)4 ISoliniaSpell (com.solinia.solinia.Interfaces.ISoliniaSpell)4 DecimalFormat (java.text.DecimalFormat)4 SoliniaItemException (com.solinia.solinia.Exceptions.SoliniaItemException)3 SoliniaActiveSpell (com.solinia.solinia.Models.SoliniaActiveSpell)3 File (java.io.File)3 EventHandler (net.md_5.bungee.event.EventHandler)3