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);
}
}
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;
}
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;
}
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);
}
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;
}
Aggregations