Search in sources :

Example 1 with Replacer

use of br.net.fabiozumbi12.RedProtect.Core.helpers.Replacer in project RedProtect by FabioZumbi12.

the class LangManager method sendMessage.

public void sendMessage(CommandSender sender, String key, Replacer[] replaces) {
    if (sender instanceof Player && delayedMessage.containsKey(sender.getName()) && delayedMessage.get(sender.getName()).equals(key)) {
        return;
    }
    if (loadedLang.get(key) == null) {
        sender.sendMessage(get("_redprotect.prefix") + " " + ChatColor.translateAlternateColorCodes('&', key));
    } else if (get(key).equalsIgnoreCase("")) {
        return;
    } else {
        String message = get(key);
        for (Replacer replacer : replaces) {
            message = message.replace(replacer.getPlaceholder(), replacer.getValue());
        }
        sender.sendMessage(get("_redprotect.prefix") + " " + message);
    }
    if (sender instanceof Player) {
        final Player p = (Player) sender;
        delayedMessage.put(p.getName(), key);
        Bukkit.getScheduler().scheduleSyncDelayedTask(RedProtect.get(), () -> delayedMessage.remove(p.getName()), 20);
    }
}
Also used : Player(org.bukkit.entity.Player) Replacer(br.net.fabiozumbi12.RedProtect.Core.helpers.Replacer)

Example 2 with Replacer

use of br.net.fabiozumbi12.RedProtect.Core.helpers.Replacer in project RedProtect by FabioZumbi12.

the class AddBlockCommand method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (args.length == 2) {
        Player player = Bukkit.getPlayer(args[0]);
        if (player == null) {
            RedProtect.get().getLanguageManager().sendMessage(sender, "cmdmanager.noplayer.online");
            return true;
        }
        int blocks;
        try {
            blocks = Integer.getInteger(args[1]);
        } catch (Exception ex) {
            RedProtect.get().getLanguageManager().sendMessage(sender, "cmdmanager.region.invalid.number");
            return true;
        }
        long total = RedProtect.get().getBlockManager().addBlock(blocks, player);
        RedProtect.get().getLanguageManager().sendMessage(sender, "cmdmanager.region.totalblocks", new Replacer[] { new Replacer("blocks", String.valueOf(total)), new Replacer("player", player.getName()) });
        return true;
    }
    RedProtect.get().getLanguageManager().sendCommandHelp(sender, "addblock", true);
    return true;
}
Also used : Player(org.bukkit.entity.Player) Replacer(br.net.fabiozumbi12.RedProtect.Core.helpers.Replacer)

Example 3 with Replacer

use of br.net.fabiozumbi12.RedProtect.Core.helpers.Replacer in project RedProtect by FabioZumbi12.

the class DelBlockCommand method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (args.length == 2) {
        Player player = Bukkit.getPlayer(args[0]);
        if (player == null) {
            RedProtect.get().getLanguageManager().sendMessage(sender, "cmdmanager.noplayer.online");
            return true;
        }
        int blocks;
        try {
            blocks = Integer.getInteger(args[1]);
        } catch (Exception ex) {
            RedProtect.get().getLanguageManager().sendMessage(sender, "cmdmanager.region.invalid.number");
            return true;
        }
        long total = RedProtect.get().getBlockManager().delBlock(blocks, player);
        RedProtect.get().getLanguageManager().sendMessage(sender, "cmdmanager.region.totalblocks", new Replacer[] { new Replacer("blocks", String.valueOf(total)), new Replacer("player", player.getName()) });
        return true;
    }
    RedProtect.get().getLanguageManager().sendCommandHelp(sender, "delblock", true);
    return true;
}
Also used : Player(org.bukkit.entity.Player) Replacer(br.net.fabiozumbi12.RedProtect.Core.helpers.Replacer)

Example 4 with Replacer

use of br.net.fabiozumbi12.RedProtect.Core.helpers.Replacer in project RedProtect by FabioZumbi12.

the class FlagGui method open.

public void open() {
    for (Player player : Sponge.getServer().getOnlinePlayers()) {
        if (player.getOpenInventory().isPresent() && player.getOpenInventory().get().getName().get().equals(this.inv.getName().get())) {
            Region r = RedProtect.get().getRegionManager().getTopRegion(player.getLocation(), this.getClass().getName());
            if (r != null && r.equals(this.region) && !player.equals(this.player)) {
                RedProtect.get().getLanguageManager().sendMessage(this.player, "cmdmanager.region.rpgui-other", new Replacer[] { new Replacer("{player}", player.getName()) });
                return;
            }
        }
    }
    // Register Listener
    Sponge.getGame().getEventManager().registerListeners(RedProtect.get().container, this);
    RedProtect.get().getVersionHelper().openInventory(this.inv, this.player);
}
Also used : Player(org.spongepowered.api.entity.living.player.Player) Region(br.net.fabiozumbi12.RedProtect.Sponge.Region) Replacer(br.net.fabiozumbi12.RedProtect.Core.helpers.Replacer)

Example 5 with Replacer

use of br.net.fabiozumbi12.RedProtect.Core.helpers.Replacer in project RedProtect by FabioZumbi12.

the class PurgeLimitCommand method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (sender instanceof ConsoleCommandSender || !RedProtect.get().getConfigManager().configRoot().purge.enabled) {
        HandleHelpPage(sender, 1);
        return true;
    }
    Player player = (Player) sender;
    int limit = RedProtect.get().getPermissionHandler().getPurgeLimit(player);
    long amount = RedProtect.get().getRegionManager().getCanPurgePlayer(player.getUniqueId().toString(), player.getWorld().getName());
    RedProtect.get().getLanguageManager().sendMessage(player, "playerlistener.region.purge-limit", new Replacer[] { new Replacer("{limit}", String.valueOf(limit)), new Replacer("{total}", String.valueOf(amount)) });
    return true;
}
Also used : Player(org.bukkit.entity.Player) Replacer(br.net.fabiozumbi12.RedProtect.Core.helpers.Replacer) ConsoleCommandSender(org.bukkit.command.ConsoleCommandSender)

Aggregations

Replacer (br.net.fabiozumbi12.RedProtect.Core.helpers.Replacer)11 Player (org.bukkit.entity.Player)7 Region (br.net.fabiozumbi12.RedProtect.Bukkit.Region)4 Region (br.net.fabiozumbi12.RedProtect.Sponge.Region)3 Player (org.spongepowered.api.entity.living.player.Player)3 java.util (java.util)2 Collectors (java.util.stream.Collectors)2 ClanPlayer (net.sacredlabyrinth.phaed.simpleclans.ClanPlayer)2 ConsoleCommandSender (org.bukkit.command.ConsoleCommandSender)2 DeleteRegionEvent (br.net.fabiozumbi12.RedProtect.Bukkit.API.events.DeleteRegionEvent)1 RenameRegionEvent (br.net.fabiozumbi12.RedProtect.Bukkit.API.events.RenameRegionEvent)1 RedProtect (br.net.fabiozumbi12.RedProtect.Bukkit.RedProtect)1 ItemFlagGui (br.net.fabiozumbi12.RedProtect.Bukkit.guis.ItemFlagGui)1 MobFlagGui (br.net.fabiozumbi12.RedProtect.Bukkit.guis.MobFlagGui)1 PlayerRegion (br.net.fabiozumbi12.RedProtect.Core.region.PlayerRegion)1 RedProtect (br.net.fabiozumbi12.RedProtect.Sponge.RedProtect)1 DeleteRegionEvent (br.net.fabiozumbi12.RedProtect.Sponge.events.DeleteRegionEvent)1 RenameRegionEvent (br.net.fabiozumbi12.RedProtect.Sponge.events.RenameRegionEvent)1 ItemFlagGui (br.net.fabiozumbi12.RedProtect.Sponge.guis.ItemFlagGui)1 UltimateFancy (br.net.fabiozumbi12.UltimateFancy.UltimateFancy)1