Initial commit
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
package net.crankedpvp.spawners.commands;
|
||||
|
||||
import me.mattstudios.mf.annotations.Alias;
|
||||
import me.mattstudios.mf.annotations.Command;
|
||||
import me.mattstudios.mf.annotations.Default;
|
||||
import me.mattstudios.mf.annotations.Optional;
|
||||
import me.mattstudios.mf.base.CommandBase;
|
||||
import net.crankedpvp.crankedutils.utils.CC;
|
||||
import net.crankedpvp.crankedutils.utils.NumberUtils;
|
||||
import net.crankedpvp.spawners.SpawnerPlugin;
|
||||
import net.crankedpvp.spawners.data.ftop.FactionData;
|
||||
import net.crankedpvp.spawners.struct.ftop.FactionsTopManager;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Command("ftop")
|
||||
@Alias("ftopp")
|
||||
public class CommandFactionsTop extends CommandBase {
|
||||
|
||||
private final FactionsTopManager factionsTopManager;
|
||||
|
||||
public CommandFactionsTop(SpawnerPlugin plugin) {
|
||||
this.factionsTopManager = plugin.getFactionsTopManager();
|
||||
}
|
||||
|
||||
@Default
|
||||
public void onCommand(CommandSender sender, @Optional Integer page) {
|
||||
Player player = (Player)sender;
|
||||
if (page == null) {
|
||||
page = 1;
|
||||
}
|
||||
page = Math.min(5, Math.max(1, page));
|
||||
player.sendMessage("");
|
||||
player.sendMessage(CC.GoldB + "Top Factions (" + CC.WhiteB + page + CC.Gold + "/" + CC.WhiteB + "5" + CC.GoldB + ")");
|
||||
int pos = 1;
|
||||
int from = (page - 1) * 9;
|
||||
int to = (page - 1) * 9 + 9;
|
||||
Map<Integer, FactionData> data = this.factionsTopManager.getTopFactions(from, to);
|
||||
for (int x = from; x < to; x++) {
|
||||
if (data.containsKey(x)) {
|
||||
FactionData faction = data.get(x);
|
||||
TextComponent msg = new TextComponent(CC.GoldB + pos + ". " + CC.Green + faction.getFaction().getTag() + CC.Gold + " - " + CC.WhiteB + "$" + NumberUtils.formatMoney(faction.getSpawnerValue()));
|
||||
String builder = CC.GoldB + CC.Underline + faction.getFaction().getTag() + "\n\n" +
|
||||
CC.White + "Member Wealth: " + CC.Gold + "$" + NumberUtils.formatMoney(faction.getMemberValue()) + "\n" +
|
||||
CC.White + "Spawner Value: " + CC.Gold + "$" + NumberUtils.formatMoney(faction.getSpawnerValue()) + "\n" +
|
||||
CC.White + "Spawners: " + CC.Gold + faction.getSpawnerCount() + "\n" +
|
||||
CC.White + "Stacked Spawners: " + CC.Gold + faction
|
||||
.getStackedSpawnerCount() +
|
||||
"\n" +
|
||||
CC.White + "Richest Member:\n" +
|
||||
" " + CC.GoldB + faction.getRichestPlayer() + ": $" + NumberUtils.formatMoney(faction.getRichestPlayerBalance());
|
||||
msg.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, (new ComponentBuilder(builder)).create()));
|
||||
player.sendMessage(msg);
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
player.sendMessage("");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user