use of br.net.fabiozumbi12.UltimateFancy.UltimateFancy in project UltimateChat by FabioZumbi12.
the class UCListener method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
UChat.get().getUCLogger().debug("onCommand - Label: " + label + " - CmdName: " + cmd.getName());
if (args.length == 1) {
if (args[0].equalsIgnoreCase("?") || args[0].equalsIgnoreCase("help")) {
sendHelp(sender);
return true;
}
if (args[0].equalsIgnoreCase("reload") && UCPerms.hasPermission(sender, "uchat.cmd.reload")) {
UChat.get().reload();
UChat.get().getLang().sendMessage(sender, "plugin.reloaded");
return true;
}
}
if (sender instanceof Player) {
Player p = (Player) sender;
if (cmd.getName().equalsIgnoreCase("channel")) {
if (args.length == 0) {
UCChannel ch = UChat.get().getChannel(label);
if (ch != null) {
addPlayerToChannel(ch, p);
} else {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.dontexist").replace("{channel}", label));
}
return true;
}
if (args.length >= 1) {
UCChannel ch = UChat.get().getChannel(label);
StringBuilder msgBuild = new StringBuilder();
for (String arg : args) {
msgBuild.append(" ").append(arg);
}
String msg = msgBuild.toString().substring(1);
if (ch != null) {
sendMessageToPlayer(ch, p, args, msg);
return true;
}
}
// if /ch or /channel
if (label.equalsIgnoreCase("ch") || label.equalsIgnoreCase("channel")) {
if (args.length == 1) {
// ch list
if (args[0].equalsIgnoreCase("list")) {
UltimateFancy fancy = new UltimateFancy();
fancy.coloredText("&7------------------------------------------\n");
fancy.coloredText(UChat.get().getLang().get("help.channels.available").replace("{channels}", "")).next();
boolean first = true;
for (UCChannel ch : UChat.get().getChannels().values()) {
if (UCPerms.channelReadPerm(p, ch) && ch.availableInWorld(p.getWorld())) {
if (first) {
fancy.coloredText(ch.getColor() + ch.getName() + "&a");
first = false;
} else {
fancy.coloredText(", " + ch.getColor() + ch.getName() + "&a");
}
fancy.hoverShowText(ch.getColor() + "Alias: " + ch.getAlias()).clickRunCmd("/" + ch.getAlias()).next();
}
}
fancy.coloredText("\n&7------------------------------------------").send(p);
return true;
}
UCChannel ch = UChat.get().getChannel(args[0]);
if (ch == null) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.dontexist").replace("{channel}", args[0]));
return true;
}
if (!UCPerms.channelReadPerm(p, ch) && !UCPerms.channelWritePerm(p, ch)) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.nopermission").replace("{channel}", ch.getName()));
return true;
}
if (!ch.availableInWorld(p.getWorld())) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.notavailable").replace("{channel}", ch.getName()));
return true;
}
if (!ch.canLock()) {
UChat.get().getLang().sendMessage(p, "help.channels.send");
return true;
}
if (ch.isMember(p)) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.alreadyon").replace("{channel}", ch.getName()));
return true;
}
if (!ch.getPassword().isEmpty()) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.password").replace("{channel}", ch.getAlias()));
return true;
}
// listen change channel event
PlayerChangeChannelEvent postEvent = new PlayerChangeChannelEvent(p, UChat.get().getPlayerChannel(p), ch);
Bukkit.getPluginManager().callEvent(postEvent);
if (postEvent.isCancelled()) {
return true;
}
ch.addMember(p);
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.entered").replace("{channel}", ch.getName()));
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.entered").replace("{channel}", ch.getName()));
return true;
}
}
sendChannelHelp(p);
}
// Listen cmd chat/uchat
if (cmd.getName().equalsIgnoreCase("uchat")) {
if (args.length == 1) {
if (args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("?")) {
sendHelp(sender);
return true;
}
if (args[0].equalsIgnoreCase("msgtoggle")) {
if (!UCPerms.cmdPerm(p, "msgtoggle")) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("cmd.nopermission"));
return true;
}
if (UChat.get().msgTogglePlayers.contains(p.getName())) {
UChat.get().msgTogglePlayers.remove(p.getName());
UChat.get().getLang().sendMessage(p, "cmd.msgtoggle.enabled");
} else {
UChat.get().msgTogglePlayers.add(p.getName());
UChat.get().getLang().sendMessage(p, "cmd.msgtoggle.disabled");
}
return true;
}
if (args[0].equalsIgnoreCase("clear")) {
if (!UCPerms.cmdPerm(p, "clear")) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("cmd.nopermission"));
return true;
}
for (int i = 0; i < 100; i++) {
if (!p.isOnline()) {
break;
}
UCUtil.performCommand(p, Bukkit.getConsoleSender(), "tellraw " + p.getName() + " {\"text\":\" \"}");
}
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("cmd.clear.cleared"));
return true;
}
if (args[0].equalsIgnoreCase("clear-all")) {
if (!UCPerms.cmdPerm(p, "clear-all")) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("cmd.nopermission"));
return true;
}
for (Player play : Bukkit.getOnlinePlayers()) {
for (int i = 0; i < 100; i++) {
if (!play.isOnline()) {
continue;
}
UCUtil.performCommand(play, Bukkit.getConsoleSender(), "tellraw " + play.getName() + " {\"text\":\" \"}");
}
}
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("cmd.clear.cleared"));
return true;
}
if (args[0].equalsIgnoreCase("spy")) {
if (!UCPerms.cmdPerm(p, "spy")) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("cmd.nopermission"));
return true;
}
if (!UChat.get().isSpy.contains(p.getName())) {
UChat.get().isSpy.add(p.getName());
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("cmd.spy.enabled"));
} else {
UChat.get().isSpy.remove(p.getName());
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("cmd.spy.disabled"));
}
return true;
}
}
if (args.length == 2) {
// chat msgtoggle <player>
if (args[0].equalsIgnoreCase("msgtoggle")) {
if (!UCPerms.hasPerm(p, "msgtoggle.others")) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("cmd.nopermission"));
return true;
}
Player vict = Bukkit.getPlayer(args[1]);
if (vict != null) {
if (UChat.get().msgTogglePlayers.contains(vict.getName())) {
UChat.get().msgTogglePlayers.remove(vict.getName());
UChat.get().getLang().sendMessage(vict, "cmd.msgtoggle.enabled");
} else {
UChat.get().msgTogglePlayers.add(vict.getName());
UChat.get().getLang().sendMessage(vict, "cmd.msgtoggle.disabled");
}
return true;
}
}
// chat delchannel <channel-name>
if (args[0].equalsIgnoreCase("delchannel")) {
if (!UCPerms.cmdPerm(p, "delchannel")) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("cmd.nopermission"));
return true;
}
UCChannel ch = UChat.get().getChannel(args[1]);
if (ch == null) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.dontexist").replace("{channel}", args[1]));
return true;
}
List<String> toAdd = new ArrayList<>(ch.getMembers());
toAdd.forEach(m -> {
UChat.get().getDefChannel(p.getWorld().getName()).addMember(m);
// listen change channel event
PlayerChangeChannelEvent postEvent = new PlayerChangeChannelEvent(p, null, UChat.get().getDefChannel(p.getWorld().getName()));
Bukkit.getPluginManager().callEvent(postEvent);
});
UChat.get().getUCConfig().delChannel(ch);
UChat.get().registerAliases();
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("cmd.delchannel.success").replace("{channel}", ch.getName()));
return true;
}
// chat ignore <channel/player>
if (args[0].equalsIgnoreCase("ignore")) {
UCChannel ch = UChat.get().getChannel(args[1]);
if (Bukkit.getPlayer(args[1]) != null) {
Player pi = Bukkit.getPlayer(args[1]);
if (!UCPerms.cmdPerm(p, "ignore.player")) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("cmd.nopermission"));
return true;
}
if (!UCPerms.canIgnore(sender, pi)) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("chat.cantignore"));
return true;
}
if (UCMessages.isIgnoringPlayers(p.getName(), pi.getName())) {
UCMessages.unIgnorePlayer(p.getName(), pi.getName());
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("player.unignoring").replace("{player}", pi.getName()));
} else {
UCMessages.ignorePlayer(p.getName(), pi.getName());
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("player.ignoring").replace("{player}", pi.getName()));
}
return true;
} else if (ch != null) {
if (!UCPerms.cmdPerm(p, "ignore.channel")) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("cmd.nopermission"));
return true;
}
if (!UCPerms.canIgnore(sender, ch)) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("chat.cantignore"));
return true;
}
if (ch.isIgnoring(p.getName())) {
ch.unIgnoreThis(p.getName());
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.notignoring").replace("{channel}", ch.getName()));
} else {
ch.ignoreThis(p.getName());
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.ignoring").replace("{channel}", ch.getName()));
}
return true;
} else {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.dontexist").replace("{channel}", args[1]));
return true;
}
}
// chat mute <player>
if (args[0].equalsIgnoreCase("mute")) {
if (!UCPerms.cmdPerm(p, "mute")) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("cmd.nopermission"));
return true;
}
String pname = args[1];
if (Bukkit.getPlayer(args[1]) != null) {
pname = Bukkit.getPlayer(args[1]).getName();
}
if (UChat.get().mutes.contains(pname)) {
UChat.get().mutes.remove(pname);
UChat.get().unMuteInAllChannels(pname);
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.unmuted.all").replace("{player}", pname));
if (Bukkit.getPlayer(pname) != null) {
UChat.get().getLang().sendMessage(Bukkit.getPlayer(args[1]), "channel.player.unmuted.all");
}
} else {
UChat.get().mutes.add(pname);
UChat.get().muteInAllChannels(pname);
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.muted.all").replace("{player}", pname));
if (Bukkit.getPlayer(pname) != null) {
UChat.get().getLang().sendMessage(Bukkit.getPlayer(args[1]), "channel.player.muted.all");
}
}
return true;
}
}
if (args.length == 3) {
// chat tempmute <minutes> <player>
if (args[0].equalsIgnoreCase("tempmute")) {
if (!UCPerms.cmdPerm(p, "tempmute")) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("cmd.nopermission"));
return true;
}
int time = 0;
try {
time = Integer.parseInt(args[1]);
} catch (Exception ex) {
UChat.get().getLang().sendMessage(p, "cmd.tempmute.number");
return true;
}
String pname = args[2];
if (Bukkit.getPlayer(args[2]) != null) {
pname = Bukkit.getPlayer(args[2]).getName();
}
if (UChat.get().mutes.contains(pname)) {
UChat.get().getLang().sendMessage(p, "channel.already.muted");
} else {
UChat.get().mutes.add(pname);
UChat.get().muteInAllChannels(pname);
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.tempmuted.all").replace("{player}", pname).replace("{time}", String.valueOf(time)));
if (Bukkit.getPlayer(pname) != null) {
UChat.get().getLang().sendMessage(Bukkit.getPlayer(args[2]), UChat.get().getLang().get("channel.player.tempmuted.all").replace("{time}", String.valueOf(time)));
}
// mute counter
new MuteCountDown(pname, time).runTaskTimer(UChat.get(), 20, 20);
}
return true;
}
// chat mute <player> <channel>
if (args[0].equalsIgnoreCase("mute")) {
if (!UCPerms.cmdPerm(p, "mute")) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("cmd.nopermission"));
return true;
}
UCChannel ch = UChat.get().getChannel(args[2]);
if (ch == null) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.dontexist").replace("{channel}", args[2]));
return true;
}
String pname = args[1];
if (Bukkit.getPlayer(args[1]) != null) {
pname = Bukkit.getPlayer(args[1]).getName();
}
if (ch.isMuted(pname)) {
ch.unMuteThis(pname);
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.unmuted.this").replace("{player}", pname).replace("{channel}", ch.getName()));
if (Bukkit.getPlayer(pname) != null) {
UChat.get().getLang().sendMessage(Bukkit.getPlayer(args[1]), UChat.get().getLang().get("channel.player.unmuted.this").replace("{channel}", ch.getName()));
}
} else {
ch.muteThis(pname);
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.muted.this").replace("{player}", pname).replace("{channel}", ch.getName()));
if (Bukkit.getPlayer(pname) != null) {
UChat.get().getLang().sendMessage(Bukkit.getPlayer(args[1]), UChat.get().getLang().get("channel.player.muted.this").replace("{channel}", ch.getName()));
}
}
return true;
}
}
if (args.length == 4) {
// chat newchannel <channel-name> <alias> <color>
if (args[0].equalsIgnoreCase("newchannel")) {
if (!UCPerms.cmdPerm(p, "newchannel")) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("cmd.nopermission"));
return true;
}
UCChannel ch = UChat.get().getChannel(args[1]);
if (ch != null) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.alreadyexists").replace("{channel}", ch.getName()));
return true;
}
String color = args[3];
if (color.length() != 2 || !color.matches("(&([A-Fa-fK-Ok-oRr0-9]))$")) {
UChat.get().getLang().sendMessage(p, "channel.invalidcolor");
return true;
}
UCChannel newch = new UCChannel(args[1], args[2], args[3]);
try {
UChat.get().getUCConfig().addChannel(newch);
} catch (IOException e) {
e.printStackTrace();
}
UChat.get().registerAliases();
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("cmd.newchannel.success").replace("{channel}", newch.getName()));
return true;
}
// chat chconfig <channel> <key> <value>
if (args[0].equalsIgnoreCase("chconfig")) {
if (!UCPerms.cmdPerm(p, "chconfig")) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("cmd.nopermission"));
return true;
}
UCChannel ch = UChat.get().getChannel(args[1]);
if (ch == null) {
UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.dontexist").replace("{channel}", args[1]));
return true;
}
if (!ch.getProperties().containsKey(args[2])) {
UChat.get().getLang().sendMessage(p, "cmd.chconfig.invalidkey");
return true;
}
UChat.get().getUCConfig().delChannel(ch);
ch.setProperty(args[2], args[3]);
try {
UChat.get().getUCConfig().addChannel(ch);
} catch (IOException e) {
e.printStackTrace();
}
UChat.get().registerAliases();
UChat.get().getLang().sendMessage(p, "cmd.chconfig.success");
return true;
}
}
}
} else {
if (UChat.get().getChAliases().contains(label.toLowerCase())) {
if (args.length >= 1) {
UCChannel ch = UChat.get().getChannel(label);
StringBuilder msgb = new StringBuilder();
for (String arg : args) {
msgb.append(" ").append(arg);
}
String msg = msgb.toString().substring(1);
UCMessages.sendFancyMessage(new String[0], msg, ch, sender, null);
return true;
}
}
}
if (cmd.getName().equalsIgnoreCase("ubroadcast") && UCPerms.cmdPerm(sender, "broadcast")) {
if (!UCUtil.sendBroadcast(sender, args, false)) {
sendHelp(sender);
}
return true;
}
if (cmd.getName().equalsIgnoreCase("umsg") && UCPerms.cmdPerm(sender, "umsg")) {
if (!UCUtil.sendUmsg(sender, args)) {
sendHelp(sender);
}
return true;
}
if (args.length == 0) {
sender.sendMessage(ChatColor.AQUA + "---------------- " + UChat.get().getPDF().getFullName() + " ----------------");
sender.sendMessage(ChatColor.AQUA + "Developed by " + ChatColor.GOLD + UChat.get().getPDF().getAuthors() + ".");
sender.sendMessage(ChatColor.AQUA + "For more information about the commands, type [" + ChatColor.GOLD + "/" + label + " ?" + ChatColor.AQUA + "].");
sender.sendMessage(ChatColor.AQUA + "---------------------------------------------------");
return true;
} else {
sendHelp(sender);
}
return true;
}
use of br.net.fabiozumbi12.UltimateFancy.UltimateFancy in project UltimateChat by FabioZumbi12.
the class UCMessages method sendFancyMessage.
protected static boolean sendFancyMessage(String[] format, String msg, UCChannel channel, CommandSender sender, CommandSender tellReceiver) {
// Execute listener:
HashMap<String, String> tags = new HashMap<>();
for (String str : UChat.get().getUCConfig().getStringList("api.legendchat-tags")) {
tags.put(str, str);
}
SendChannelMessageEvent event = new SendChannelMessageEvent(tags, format, sender, channel, msg);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return event.getCancelIncomingChat();
}
boolean cancel = event.getCancelIncomingChat();
// String toConsole = "";
registeredReplacers = event.getResgisteredTags();
defFormat = event.getDefFormat();
String evmsg = event.getMessage();
HashMap<CommandSender, UltimateFancy> msgPlayers = new HashMap<>();
evmsg = composeColor(sender, evmsg);
if (event.getChannel() != null) {
UCChannel ch = event.getChannel();
if (sender instanceof Player && !ch.availableWorlds().isEmpty() && !ch.availableInWorld(((Player) sender).getWorld())) {
UChat.get().getLang().sendMessage(sender, UChat.get().getLang().get("channel.notavailable").replace("{channel}", ch.getName()));
return cancel;
}
if (!UCPerms.channelWritePerm(sender, ch)) {
UChat.get().getLang().sendMessage(sender, UChat.get().getLang().get("channel.nopermission").replace("{channel}", ch.getName()));
return cancel;
}
if (ch.isMuted(sender.getName())) {
UChat.get().getLang().sendMessage(sender, "channel.muted");
return cancel;
}
if (!UCPerms.hasPerm(sender, "bypass.cost") && UChat.get().getVaultEco() != null && sender instanceof Player && ch.getCost() > 0) {
if (UChat.get().getVaultEco().getBalance((Player) sender, ((Player) sender).getWorld().getName()) < ch.getCost()) {
UChat.get().getLang().sendMessage(sender, UChat.get().getLang().get("channel.cost").replace("{value}", "" + ch.getCost()));
return cancel;
} else {
UChat.get().getVaultEco().withdrawPlayer((Player) sender, ((Player) sender).getWorld().getName(), ch.getCost());
}
}
List<Player> receivers = new ArrayList<>();
int noWorldReceived = 0;
int vanish = 0;
// put sender
msgPlayers.put(sender, sendMessage(sender, sender, evmsg, ch, false));
if (ch.getDistance() > 0 && sender instanceof Player) {
for (Player play : ((Player) sender).getNearbyEntities(ch.getDistance(), ch.getDistance(), ch.getDistance()).stream().filter(ent -> ent instanceof Player).map(ent -> (Player) ent).collect(Collectors.toList())) {
if (UCPerms.channelReadPerm(play, ch)) {
if (!ch.availableWorlds().isEmpty() && !ch.availableInWorld(play.getWorld())) {
continue;
}
if (ch.isIgnoring(play.getName())) {
continue;
}
if (isIgnoringPlayers(play.getName(), sender.getName())) {
noWorldReceived++;
continue;
}
if (!((Player) sender).canSee(play)) {
vanish++;
}
if (!ch.neeFocus() || ch.isMember(play)) {
msgPlayers.put(play, sendMessage(sender, play, evmsg, ch, false));
receivers.add(play);
}
}
}
} else {
for (Player receiver : UChat.get().getServer().getOnlinePlayers()) {
if (receiver.equals(sender) || !UCPerms.channelReadPerm(receiver, ch) || (!ch.crossWorlds() && (sender instanceof Player && !receiver.getWorld().equals(((Player) sender).getWorld())))) {
continue;
}
if (!ch.availableWorlds().isEmpty() && !ch.availableInWorld(receiver.getWorld())) {
continue;
}
if (ch.isIgnoring(receiver.getName())) {
continue;
}
if (isIgnoringPlayers(receiver.getName(), sender.getName())) {
noWorldReceived++;
continue;
}
if (sender instanceof Player && (!((Player) sender).canSee(receiver))) {
vanish++;
} else {
noWorldReceived++;
}
if (!ch.neeFocus() || ch.isMember(receiver)) {
msgPlayers.put(receiver, sendMessage(sender, receiver, evmsg, ch, false));
receivers.add(receiver);
}
}
}
// chat spy
if (!UCPerms.hasPermission(sender, "uchat.chat-spy.bypass")) {
for (Player receiver : UChat.get().getServer().getOnlinePlayers()) {
if (!receiver.equals(sender) && !receivers.contains(receiver) && !receivers.contains(sender) && UChat.get().isSpy.contains(receiver.getName()) && UCPerms.hasSpyPerm(receiver, ch.getName())) {
String spyformat = UChat.get().getUCConfig().getString("general.spy-format");
spyformat = spyformat.replace("{output}", ChatColor.stripColor(sendMessage(sender, receiver, evmsg, ch, true).toOldFormat()));
receiver.sendMessage(ChatColor.translateAlternateColorCodes('&', spyformat));
}
}
}
if (ch.getDistance() == 0 && noWorldReceived <= 0) {
if (ch.getReceiversMsg()) {
UChat.get().getLang().sendMessage(sender, "channel.noplayer.world");
}
}
if ((receivers.size() - vanish) <= 0) {
if (ch.getReceiversMsg()) {
UChat.get().getLang().sendMessage(sender, "channel.noplayer.near");
}
}
} else {
if (UChat.get().msgTogglePlayers.contains(tellReceiver.getName()) && !sender.hasPermission("uchat.msgtoggle.exempt")) {
UChat.get().getLang().sendMessage(sender, "cmd.msgtoggle.msgdisabled");
return cancel;
}
channel = new UCChannel("tell");
// send spy
if (!UCPerms.hasPermission(sender, "uchat.chat-spy.bypass")) {
for (Player receiver : UChat.get().getServer().getOnlinePlayers()) {
if (!receiver.equals(tellReceiver) && !receiver.equals(sender) && UChat.get().isSpy.contains(receiver.getName()) && UCPerms.hasSpyPerm(receiver, "private")) {
String spyformat = UChat.get().getUCConfig().getString("general.spy-format");
if (isIgnoringPlayers(tellReceiver.getName(), sender.getName())) {
spyformat = UChat.get().getLang().get("chat.ignored") + spyformat;
}
spyformat = spyformat.replace("{output}", ChatColor.stripColor(sendMessage(sender, tellReceiver, evmsg, channel, true).toOldFormat()));
receiver.sendMessage(ChatColor.translateAlternateColorCodes('&', spyformat));
}
}
}
msgPlayers.put(sender, sendMessage(sender, tellReceiver, evmsg, channel, false));
if (!isIgnoringPlayers(tellReceiver.getName(), sender.getName())) {
msgPlayers.put(tellReceiver, sendMessage(sender, tellReceiver, evmsg, channel, false));
}
if (isIgnoringPlayers(tellReceiver.getName(), sender.getName())) {
msgPlayers.put(UChat.get().getServer().getConsoleSender(), new UltimateFancy(UChat.get().getLang().get("chat.ignored") + msgPlayers.get(sender).toOldFormat()));
}
}
if (!msgPlayers.keySet().contains(UChat.get().getServer().getConsoleSender())) {
msgPlayers.put(UChat.get().getServer().getConsoleSender(), msgPlayers.get(sender));
}
// fire post event
PostFormatChatMessageEvent postEvent = new PostFormatChatMessageEvent(sender, msgPlayers, channel, msg);
Bukkit.getPluginManager().callEvent(postEvent);
if (postEvent.isCancelled()) {
return cancel;
}
if (channel != null && !channel.isTell() && channel.isBungee()) {
UChatBungee.sendBungee(channel, msgPlayers.get(sender));
} else {
msgPlayers.forEach((send, text) -> {
UChat.get().getUCLogger().timings(timingType.END, "UCMessages#send()|before send");
text.send(send);
UChat.get().getUCLogger().timings(timingType.END, "UCMessages#send()|after send");
});
}
if (channel != null) {
// send to jedis
if (!channel.isTell() && UChat.get().getJedis() != null) {
UChat.get().getJedis().sendMessage(channel.getName().toLowerCase(), msgPlayers.get(sender));
}
// send to jda
if (UChat.get().getUCJDA() != null) {
if (channel.isTell()) {
UChat.get().getUCJDA().sendTellToDiscord(msgPlayers.get(sender).toOldFormat());
} else {
UChat.get().getUCJDA().sendToDiscord(sender, evmsg, channel);
}
}
}
return cancel;
}
use of br.net.fabiozumbi12.UltimateFancy.UltimateFancy in project RedProtect by FabioZumbi12.
the class CommandHandler method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length > 0 && hasCommand(args[0])) {
CommandExecutor executor = this.getCommandSubCommand(args[0]);
return executor.onCommand(sender, command, label, Arrays_copyOfRange(args, args.length));
} else {
if (args.length == 0 || !RedProtect.get().getPermissionHandler().hasCommandPerm(sender, "admin")) {
HandleHelpPage(sender, 1);
return true;
}
if (args.length == 1) {
if (args[0].equalsIgnoreCase("debug-item")) {
if (sender instanceof Player) {
ItemStack hand = ((Player) sender).getItemInHand();
plugin.getLanguageManager().sendMessage(sender, "&aMaterial name: " + hand.getType().name());
} else {
plugin.getLanguageManager().sendMessage(sender, "&cThis command can be used only by online players holding an item!");
}
return true;
}
if (args[0].equalsIgnoreCase("update")) {
if (plugin.getUpdater() == null) {
plugin.getLanguageManager().sendMessage(sender, "&aPlugin updates is disabled on config.");
return true;
}
if (plugin.getUpdater().getUpdateAvailable() == SpigetUpdater.UpdateStatus.AVAILABLE)
plugin.getUpdater().downloadAndUpdateJar(sender);
else if (plugin.getUpdater().getUpdateAvailable() == SpigetUpdater.UpdateStatus.RESTART_NEEDED)
plugin.getLanguageManager().sendMessage(sender, "&aPlugin updated. Restart server to complete the update.");
else
plugin.getUpdater().checkForUpdate(sender, false);
return true;
}
if (args[0].equalsIgnoreCase("reset-uuids")) {
final boolean[] save = { false };
// Reset uuids
RedProtect.get().getRegionManager().getAllRegions().forEach(r -> {
r.getLeaders().forEach(rp -> {
if (RedProtect.get().getUtil().isUUIDs(rp.getUUID())) {
rp.setUUID(rp.getPlayerName());
save[0] = true;
}
});
r.getAdmins().forEach(rp -> {
if (RedProtect.get().getUtil().isUUIDs(rp.getUUID())) {
rp.setUUID(rp.getPlayerName());
save[0] = true;
}
});
r.getMembers().forEach(rp -> {
if (RedProtect.get().getUtil().isUUIDs(rp.getUUID())) {
rp.setUUID(rp.getPlayerName());
save[0] = true;
}
});
// Set uudis for online players
Bukkit.getOnlinePlayers().forEach(p -> {
if (RedProtect.get().getConfigManager().configRoot().online_mode) {
// Update player names based on uuids
r.getLeaders().forEach(rp -> {
if (rp.getUUID().equalsIgnoreCase(p.getUniqueId().toString()) && !rp.getPlayerName().equalsIgnoreCase(p.getName())) {
rp.setPlayerName(p.getName().toLowerCase());
r.setToSave(true);
}
});
r.getAdmins().forEach(rp -> {
if (rp.getUUID().equalsIgnoreCase(p.getUniqueId().toString()) && !rp.getPlayerName().equalsIgnoreCase(p.getName())) {
rp.setPlayerName(p.getName().toLowerCase());
r.setToSave(true);
}
});
r.getMembers().forEach(rp -> {
if (rp.getUUID().equalsIgnoreCase(p.getUniqueId().toString()) && !rp.getPlayerName().equalsIgnoreCase(p.getName())) {
rp.setPlayerName(p.getName().toLowerCase());
r.setToSave(true);
}
});
} else {
// Update uuids based on player names
r.getLeaders().forEach(rp -> {
if (rp.getPlayerName().equalsIgnoreCase(p.getName()) && !rp.getUUID().equalsIgnoreCase(p.getUniqueId().toString())) {
rp.setUUID(p.getUniqueId().toString());
r.setToSave(true);
}
});
r.getAdmins().forEach(rp -> {
if (rp.getPlayerName().equalsIgnoreCase(p.getName()) && !rp.getUUID().equalsIgnoreCase(p.getUniqueId().toString())) {
rp.setUUID(p.getUniqueId().toString());
r.setToSave(true);
}
});
r.getMembers().forEach(rp -> {
if (rp.getPlayerName().equalsIgnoreCase(p.getName()) && !rp.getUUID().equalsIgnoreCase(p.getUniqueId().toString())) {
rp.setUUID(p.getUniqueId().toString());
r.setToSave(true);
}
});
}
});
});
if (save[0]) {
RedProtect.get().getRegionManager().saveAll(true);
RedProtect.get().logger.success("Fixed some online players uuids!");
} else {
RedProtect.get().logger.success("No uuids fixed!");
}
return true;
}
if (args[0].equalsIgnoreCase("clear-kicks")) {
RedProtect.get().denyEnter.clear();
RedProtect.get().logger.success("All region kicks was clear");
return true;
}
if (args[0].equalsIgnoreCase("single-to-files")) {
RedProtect.get().logger.success("[" + RedProtect.get().getUtil().SingleToFiles() + "]" + " regions converted to your own files with success");
return true;
}
if (args[0].equalsIgnoreCase("files-to-single")) {
RedProtect.get().logger.success("[" + RedProtect.get().getUtil().FilesToSingle() + "]" + " regions converted to unified database file with success");
return true;
}
if (args[0].equalsIgnoreCase("fileToMysql")) {
try {
if (!RedProtect.get().getUtil().fileToMysql()) {
RedProtect.get().logger.severe("ERROR: Check if your 'file-type' configuration is set to 'file' before convert from FILE to Mysql.");
return true;
} else {
RedProtect.get().getConfig().set("file-type", "mysql");
RedProtect.get().saveConfig();
RedProtect.get().getServer().getPluginManager().disablePlugin(RedProtect.get());
RedProtect.get().getServer().getPluginManager().enablePlugin(RedProtect.get());
RedProtect.get().logger.success("RedProtect reloaded with Mysql as database! Ready to use!");
return true;
}
} catch (Exception e) {
CoreUtil.printJarVersion();
e.printStackTrace();
return true;
}
}
if (args[0].equalsIgnoreCase("mysqlToFile")) {
try {
if (!RedProtect.get().getUtil().mysqlToFile()) {
RedProtect.get().logger.severe("ERROR: Check if your 'file-type' configuration is set to 'mysql' before convert from MYSQL to FILE.");
return true;
} else {
RedProtect.get().getConfig().set("file-type", "file");
RedProtect.get().saveConfig();
RedProtect.get().getServer().getPluginManager().disablePlugin(RedProtect.get());
RedProtect.get().getServer().getPluginManager().enablePlugin(RedProtect.get());
RedProtect.get().logger.success("RedProtect reloaded with File as database! Ready to use!");
return true;
}
} catch (Exception e) {
CoreUtil.printJarVersion();
e.printStackTrace();
return true;
}
}
if (args[0].equalsIgnoreCase("gpTorp")) {
if (!RedProtect.get().hooks.checkGriefPrev()) {
RedProtect.get().logger.success("The plugin GriefPrevention is not installed or is disabled");
return true;
}
if (RedProtect.get().getUtil().convertFromGP() == 0) {
RedProtect.get().logger.severe("No region converted from GriefPrevention.");
return true;
} else {
RedProtect.get().getRegionManager().saveAll(true);
RedProtect.get().logger.info(ChatColor.AQUA + "[" + RedProtect.get().getUtil().convertFromGP() + "] regions converted from GriefPrevention with success");
RedProtect.get().getServer().getPluginManager().disablePlugin(RedProtect.get());
RedProtect.get().getServer().getPluginManager().enablePlugin(RedProtect.get());
return true;
}
}
if (args[0].equalsIgnoreCase("list-all")) {
int total = 0;
for (Region r : RedProtect.get().getRegionManager().getAllRegions()) {
RedProtect.get().logger.info(ChatColor.GREEN + "[" + total + "]" + "Region: " + r.getName() + ChatColor.RESET + " | " + ChatColor.AQUA + "World: " + r.getWorld() + ChatColor.RESET);
total++;
}
RedProtect.get().logger.success(total + " regions for " + Bukkit.getWorlds().size() + " worlds.");
return true;
}
if (args[0].equalsIgnoreCase("mychunktorp")) {
RedProtect.get().logger.success("...converting MyChunk database");
if (handleMyChunk()) {
RedProtect.get().getRegionManager().saveAll(true);
RedProtect.get().getServer().getPluginManager().disablePlugin(RedProtect.get());
RedProtect.get().getServer().getPluginManager().enablePlugin(RedProtect.get());
return true;
} else {
RedProtect.get().logger.success("The plugin MyChunk is not installed or no regions found");
return true;
}
}
if (args[0].equalsIgnoreCase("wgtorp")) {
RedProtect.get().logger.success("...converting WorldGuard database");
if (handleWGRegions()) {
RedProtect.get().getRegionManager().saveAll(true);
RedProtect.get().getServer().getPluginManager().disablePlugin(RedProtect.get());
RedProtect.get().getServer().getPluginManager().enablePlugin(RedProtect.get());
return true;
} else {
RedProtect.get().logger.success("The plugin WorldGuard is not installed or no regions found");
return true;
}
}
if (args[0].equalsIgnoreCase("load-all")) {
RedProtect.get().getRegionManager().clearDB();
try {
RedProtect.get().getRegionManager().loadAll();
RedProtect.get().getUtil().ReadAllDB(RedProtect.get().getRegionManager().getAllRegions());
} catch (Exception e) {
RedProtect.get().logger.severe("Error on load all regions from database files:");
CoreUtil.printJarVersion();
e.printStackTrace();
}
RedProtect.get().logger.success(RedProtect.get().getRegionManager().getAllRegions().size() + " regions has been loaded from database files!");
return true;
}
if (checkCmd(args[0], "reload")) {
RedProtect.get().reload();
RedProtect.get().getLanguageManager().sendMessage(sender, "RedProtect Plus reloaded!");
return true;
}
if (args[0].equalsIgnoreCase("reload-config")) {
RedProtect.get().reloadConfigs();
RedProtect.get().getLanguageManager().sendMessage(sender, "RedProtect configs reloaded!");
return true;
}
}
if (args.length == 2) {
if (args[0].equalsIgnoreCase("test-uuid")) {
try {
String name = MojangUUIDs.getUUID(args[1]);
RedProtect.get().logger.warning("Leader from: " + args[1]);
RedProtect.get().logger.warning("UUID To name: " + name);
} catch (Exception e) {
CoreUtil.printJarVersion();
e.printStackTrace();
}
return true;
}
// rp regen stop
if (checkCmd(args[0], "regenall") && args[1].equalsIgnoreCase("stop")) {
if (!RedProtect.get().hooks.checkWe()) {
return true;
}
RedProtect.get().getUtil().stopRegen = true;
RedProtect.get().getLanguageManager().sendMessage(sender, "&aRegen will stop now. To continue reload the plugin!");
return true;
}
if (args[0].equalsIgnoreCase("setconfig") && args[1].equalsIgnoreCase("list")) {
RedProtect.get().getLanguageManager().sendMessage(sender, ChatColor.AQUA + "=========== Config Sections: ===========");
for (String section : RedProtect.get().getConfig().getValues(false).keySet()) {
if (section.contains("debug-messages") || section.contains("file-type") || section.contains("language")) {
sender.sendMessage(ChatColor.GOLD + section + " : " + ChatColor.GREEN + RedProtect.get().getConfig().get(section).toString());
}
}
sender.sendMessage(ChatColor.AQUA + "====================================");
return true;
}
// rp limit player
if (checkCmd(args[0], "blocklimit")) {
Player offp = RedProtect.get().getServer().getOfflinePlayer(args[1]).getPlayer();
if (offp == null) {
RedProtect.get().getLanguageManager().sendMessage(sender, RedProtect.get().getLanguageManager().get("cmdmanager.noplayer.thisname").replace("{player}", args[1]));
return true;
}
int limit = RedProtect.get().getPermissionHandler().getPlayerBlockLimit(offp);
if (limit < 0 || RedProtect.get().getPermissionHandler().hasPerm(offp, "redprotect.limits.blocks.unlimited")) {
RedProtect.get().getLanguageManager().sendMessage(sender, RedProtect.get().getLanguageManager().get("cmdmanager.nolimit"));
return true;
}
int currentUsed = RedProtect.get().getRegionManager().getTotalRegionSize(offp.getUniqueId().toString(), offp.getWorld().getName());
ChatColor color = currentUsed >= limit ? ChatColor.RED : ChatColor.GOLD;
RedProtect.get().getLanguageManager().sendMessage(sender, RedProtect.get().getLanguageManager().get("cmdmanager.yourarea") + color + currentUsed + RedProtect.get().getLanguageManager().get("general.color") + "/" + color + limit + RedProtect.get().getLanguageManager().get("general.color"));
return true;
}
}
if (args.length == 3) {
// rp undo <region> <database>
if (args[0].equalsIgnoreCase("undo")) {
if (!RedProtect.get().hooks.checkWe()) {
return true;
}
World w = RedProtect.get().getServer().getWorld(args[2]);
if (w == null) {
RedProtect.get().getLanguageManager().sendMessage(sender, RedProtect.get().getLanguageManager().get("cmdmanager.region.invalidworld"));
return true;
}
Region r = RedProtect.get().getRegionManager().getRegion(args[1], w.getName());
if (r == null) {
RedProtect.get().getLanguageManager().sendMessage(sender, RedProtect.get().getLanguageManager().get("correct.usage") + " " + ChatColor.YELLOW + "Invalid region: " + args[1]);
return true;
}
if (WEHook.undo(r.getID())) {
RedProtect.get().getLanguageManager().sendMessage(sender, RedProtect.get().getLanguageManager().get("cmdmanager.regen.undo.sucess").replace("{region}", r.getName()));
} else {
RedProtect.get().getLanguageManager().sendMessage(sender, RedProtect.get().getLanguageManager().get("cmdmanager.regen.undo.none").replace("{region}", r.getName()));
}
return true;
}
if (args[0].equalsIgnoreCase("setconfig")) {
if (args[1].equals("debug-messages") || args[1].equals("file-type") || args[1].equals("language")) {
Object from = RedProtect.get().getConfig().get(args[1]);
if (args[2].equals("true") || args[2].equals("false")) {
RedProtect.get().getConfig().set(args[1], Boolean.parseBoolean(args[2]));
} else {
try {
int value = Integer.parseInt(args[2]);
RedProtect.get().getConfig().set(args[1], value);
} catch (NumberFormatException ex) {
RedProtect.get().getConfig().set(args[1], args[2]);
}
}
RedProtect.get().getLanguageManager().sendMessage(sender, RedProtect.get().getLanguageManager().get("cmdmanager.configset") + " " + from.toString() + " > " + args[2]);
RedProtect.get().getConfigManager().save();
return true;
} else {
RedProtect.get().getLanguageManager().sendMessage(sender, RedProtect.get().getLanguageManager().get("cmdmanager.confignotset") + " " + args[1]);
}
return true;
}
}
if (args[0].equalsIgnoreCase("list-areas")) {
int Page = 1;
if (args.length == 2) {
try {
Page = Integer.parseInt(args[1]);
} catch (Exception ignored) {
}
}
sender.sendMessage(RedProtect.get().getLanguageManager().get("general.color") + "-------------------------------------------------");
int regionsPage = RedProtect.get().getConfigManager().configRoot().region_settings.region_list.region_per_page;
int total = 0;
int last = 0;
for (World w : Bukkit.getWorlds()) {
boolean first = true;
if (Page == 0) {
Page = 1;
}
int max = (regionsPage * Page);
int min = max - regionsPage;
int count;
Set<Region> wregions = new HashSet<>();
for (Region r : RedProtect.get().getRegionManager().getRegionsByWorld(w.getName())) {
SimpleDateFormat dateformat = new SimpleDateFormat(RedProtect.get().getConfigManager().configRoot().region_settings.date_format);
Date now = null;
try {
now = dateformat.parse(RedProtect.get().getUtil().dateNow());
} catch (ParseException e1) {
RedProtect.get().logger.severe("The 'date-format' don't match with date 'now'!!");
}
Date regiondate = null;
try {
regiondate = dateformat.parse(r.getDate());
} catch (ParseException e) {
RedProtect.get().logger.severe("The 'date-format' don't match with region date!!");
CoreUtil.printJarVersion();
e.printStackTrace();
}
long days = TimeUnit.DAYS.convert(now.getTime() - regiondate.getTime(), TimeUnit.MILLISECONDS);
for (String play : RedProtect.get().getConfigManager().configRoot().purge.ignore_regions_from_players) {
if (r.isLeader(play) || r.isAdmin(play)) {
break;
}
}
if (!r.isLeader(RedProtect.get().getConfigManager().configRoot().region_settings.default_leader) && days > RedProtect.get().getConfigManager().configRoot().purge.remove_oldest && r.getArea() >= RedProtect.get().getConfigManager().configRoot().purge.regen.max_area_regen) {
wregions.add(r);
}
}
if (wregions.size() == 0) {
continue;
}
String colorChar = ChatColor.translateAlternateColorCodes('&', RedProtect.get().getConfigManager().configRoot().region_settings.world_colors.get(w.getName()));
int totalLocal = wregions.size();
total += totalLocal;
int lastLocal = 0;
if (wregions.size() > 0) {
List<Region> it = new ArrayList<>(wregions);
if (min > totalLocal) {
int diff = (totalLocal / regionsPage);
min = regionsPage * diff;
max = (regionsPage * diff) + regionsPage;
}
if (max > it.size())
max = (it.size() - 1);
// -------------
if (RedProtect.get().getConfigManager().configRoot().region_settings.region_list.hover_and_click_teleport && RedProtect.get().getPermissionHandler().hasRegionPermAdmin(sender, "teleport", null)) {
UltimateFancy fancy = new UltimateFancy(RedProtect.get());
for (int i = min; i <= max; i++) {
count = i;
Region r = it.get(i);
String rname = RedProtect.get().getLanguageManager().get("general.color") + ", " + ChatColor.GRAY + r.getName() + "(" + r.getArea() + ")";
if (first) {
rname = rname.substring(3);
first = false;
}
if (count == max) {
rname = rname + RedProtect.get().getLanguageManager().get("general.color") + ".";
}
fancy.text(rname).hoverShowText(RedProtect.get().getLanguageManager().get("cmdmanager.list.hover").replace("{region}", r.getName())).clickRunCmd("/rp " + getCmd("teleport") + " " + r.getName() + " " + r.getWorld()).next();
lastLocal = count;
}
last += lastLocal + 1;
sender.sendMessage("-----");
sender.sendMessage(RedProtect.get().getLanguageManager().get("general.color") + RedProtect.get().getLanguageManager().get("region.world").replace(":", "") + " " + colorChar + w.getName() + "[" + (min + 1) + "-" + (max + 1) + "/" + wregions.size() + "]" + ChatColor.RESET + ": ");
fancy.send(sender);
} else {
StringBuilder worldregions = new StringBuilder();
for (int i = min; i <= max; i++) {
count = i;
Region r = it.get(i);
worldregions.append(RedProtect.get().getLanguageManager().get("general.color")).append(", ").append(ChatColor.GRAY).append(r.getName()).append(r.getArea());
lastLocal = count;
}
last += lastLocal + 1;
sender.sendMessage("-----");
sender.sendMessage(RedProtect.get().getLanguageManager().get("general.color") + RedProtect.get().getLanguageManager().get("region.world").replace(":", "") + " " + colorChar + w.getName() + "[" + (min + 1) + "-" + (max + 1) + "/" + wregions.size() + "]" + ChatColor.RESET + ": ");
sender.sendMessage(worldregions.substring(3) + RedProtect.get().getLanguageManager().get("general.color") + ".");
}
// -----------
}
}
sender.sendMessage(RedProtect.get().getLanguageManager().get("general.color") + "---------------- " + last + "/" + total + " -----------------");
if (last < total) {
sender.sendMessage(RedProtect.get().getLanguageManager().get("cmdmanager.region.listpage.more").replace("{player}", "" + (Page + 1)));
} else {
if (Page != 1) {
sender.sendMessage(RedProtect.get().getLanguageManager().get("cmdmanager.region.listpage.nomore"));
}
}
return true;
}
if (args[0].equalsIgnoreCase("save-all")) {
RedProtect.get().logger.saveLogs();
RedProtect.get().logger.success(RedProtect.get().getRegionManager().saveAll(args.length == 2 && args[1].equalsIgnoreCase("-f")) + " regions saved with success!");
return true;
}
HandleHelpPage(sender, 1);
return true;
}
}
use of br.net.fabiozumbi12.UltimateFancy.UltimateFancy in project RedProtect by FabioZumbi12.
the class CommandHandlers method getRegionforList.
public static void getRegionforList(CommandSender sender, String uuid, int nPage) {
Bukkit.getScheduler().runTaskAsynchronously(RedProtect.get(), () -> {
int Page = nPage;
Set<Region> regions = RedProtect.get().getRegionManager().getLeaderRegions(uuid);
int length = regions.size();
if (length == 0) {
RedProtect.get().getLanguageManager().sendMessage(sender, "cmdmanager.player.noregions");
} else {
sender.sendMessage(RedProtect.get().getLanguageManager().get("general.color") + "-------------------------------------------------");
RedProtect.get().getLanguageManager().sendMessage(sender, RedProtect.get().getLanguageManager().get("cmdmanager.region.created.list") + " " + RedProtect.get().getUtil().UUIDtoPlayer(uuid));
int regionsPage = RedProtect.get().getConfigManager().configRoot().region_settings.region_list.region_per_page;
int total = 0;
int last = 0;
UltimateFancy fancy = new UltimateFancy(RedProtect.get());
for (World w : Bukkit.getWorlds()) {
boolean first = true;
if (Page == 0) {
Page = 1;
}
int max = (regionsPage * Page);
int min = max - regionsPage;
int count;
String colorChar = ChatColor.translateAlternateColorCodes('&', RedProtect.get().getConfigManager().configRoot().region_settings.world_colors.get(w.getName()));
Set<Region> wregions = RedProtect.get().getRegionManager().getRegions(uuid, w.getName());
int totalLocal = wregions.size();
total += totalLocal;
int lastLocal = 0;
if (wregions.size() > 0) {
List<Region> it = new ArrayList<>(wregions);
if (min > totalLocal) {
int diff = (totalLocal / regionsPage);
min = regionsPage * diff;
max = (regionsPage * diff) + regionsPage;
}
if (max >= it.size())
max = (it.size() - 1);
// -------------
UltimateFancy tempFancy = new UltimateFancy(RedProtect.get());
if (RedProtect.get().getConfigManager().configRoot().region_settings.region_list.hover_and_click_teleport && RedProtect.get().getPermissionHandler().hasRegionPermAdmin(sender, "teleport", null)) {
for (int i = min; i <= max; i++) {
count = i;
Region r = it.get(i);
String area = RedProtect.get().getConfigManager().configRoot().region_settings.region_list.shpw_area ? "(" + RedProtect.get().getUtil().simuleTotalRegionSize(RedProtect.get().getUtil().PlayerToUUID(uuid), r) + ")" : "";
String rname = RedProtect.get().getLanguageManager().get("general.color") + ", " + ChatColor.GRAY + r.getName() + area;
if (first) {
rname = rname.substring(3);
first = false;
}
if (count == max) {
rname = rname + RedProtect.get().getLanguageManager().get("general.color") + ".";
}
tempFancy.text(rname).hoverShowText(RedProtect.get().getLanguageManager().get("cmdmanager.list.hover").replace("{region}", r.getName())).clickRunCmd("/rp " + getCmd("teleport") + " " + r.getName() + " " + r.getWorld()).next();
lastLocal = count;
}
} else {
for (int i = min; i <= max; i++) {
count = i;
Region r = it.get(i);
String area = RedProtect.get().getConfigManager().configRoot().region_settings.region_list.shpw_area ? "(" + RedProtect.get().getUtil().simuleTotalRegionSize(RedProtect.get().getUtil().PlayerToUUID(uuid), r) + ")" : "";
String rname = RedProtect.get().getLanguageManager().get("general.color") + ", " + ChatColor.GRAY + r.getName() + area;
if (first) {
rname = rname.substring(3);
first = false;
}
if (count == max) {
rname = rname + RedProtect.get().getLanguageManager().get("general.color") + ".";
}
tempFancy.textAndNext(rname);
lastLocal = count;
}
}
last += lastLocal + 1;
fancy.textAndNext("\n" + RedProtect.get().getLanguageManager().get("general.color") + "-----");
fancy.textAndNext("\n" + RedProtect.get().getLanguageManager().get("general.color") + RedProtect.get().getLanguageManager().get("region.world").replace(":", "") + " " + colorChar + w.getName() + "[" + (min + 1) + "-" + (max + 1) + "/" + wregions.size() + "]" + ChatColor.RESET + ":");
fancy.appendFancy(tempFancy);
fancy.next();
}
}
fancy.textAndNext("\n" + RedProtect.get().getLanguageManager().get("general.color") + "---------------- " + last + "/" + total + " -----------------");
if (last < total) {
fancy.text("\n" + RedProtect.get().getLanguageManager().get("cmdmanager.region.listpage.more").replace("{player}", RedProtect.get().getUtil().UUIDtoPlayer(uuid) + " " + (Page + 1))).clickRunCmd("/rp list " + RedProtect.get().getUtil().UUIDtoPlayer(uuid) + " " + (Page + 1)).hoverShowText(RedProtect.get().getLanguageManager().get("general.color") + "/rp list " + RedProtect.get().getUtil().UUIDtoPlayer(uuid) + " " + (Page + 1));
} else {
if (Page != 1) {
fancy.textAndNext("\n" + RedProtect.get().getLanguageManager().get("cmdmanager.region.listpage.nomore"));
}
}
fancy.send(sender);
}
});
}
Aggregations