use of com.nextplugins.economy.configuration.RankingValue in project NextEconomy by NextPlugins.
the class NextEconomy method unloadRanking.
private void unloadRanking() {
if (CustomRankingRegistry.getInstance().isEnabled()) {
if (CustomRankingRegistry.getInstance().isHolographicDisplays()) {
HologramsAPI.getHolograms(this).forEach(Hologram::delete);
} else {
// jump concurrentmodificationexception
val holograms = new ArrayList<CMIHologram>();
val hologramManager = CMI.getInstance().getHologramManager();
for (val entry : hologramManager.getHolograms().entrySet()) {
if (entry.getKey().startsWith("NextEconomy"))
holograms.add(entry.getValue());
}
holograms.forEach(hologramManager::removeHolo);
}
String type = RankingValue.get(RankingValue::npcType);
if (type.equalsIgnoreCase("armorstand")) {
for (val stand : ArmorStandRunnable.STANDS) {
stand.remove();
}
}
getLogger().info("Sistema de ranking visual descarregado com sucesso");
}
}
use of com.nextplugins.economy.configuration.RankingValue in project NextEconomy by NextPlugins.
the class ArmorStandRunnable method run.
@Override
public void run() {
STANDS.forEach(ArmorStand::remove);
if (holographicDisplays)
HologramsAPI.getHolograms(plugin).forEach(Hologram::delete);
else {
for (val entry : HOLOGRAMS) {
val cmiHologram = CMI.getInstance().getHologramManager().getHolograms().get(entry);
if (cmiHologram == null)
continue;
CMI.getInstance().getHologramManager().removeHolo(cmiHologram);
}
}
HOLOGRAMS.clear();
STANDS.clear();
if (locationManager.getLocationMap().isEmpty())
return;
ArrayList<SimpleAccount> accounts = new ArrayList<>(rankingStorage.getRankByCoin().values());
val small = RankingValue.get(RankingValue::hologramFormat).equalsIgnoreCase("SMALL");
val height = small ? 2.15 : 3;
val hologramLines = RankingValue.get(RankingValue::hologramArmorStandLines);
val nobodyLines = RankingValue.get(RankingValue::nobodyHologramLines);
for (val entry : locationManager.getLocationMap().entrySet()) {
val position = entry.getKey();
val location = entry.getValue();
if (location == null || location.getWorld() == null)
continue;
val chunk = location.getChunk();
if (!chunk.isLoaded())
chunk.load(true);
SimpleAccount account = position - 1 < accounts.size() ? accounts.get(position - 1) : null;
if (account == null) {
if (!nobodyLines.isEmpty()) {
val hologramLocation = location.clone().add(0, height, 0);
if (holographicDisplays) {
val hologram = HologramsAPI.createHologram(plugin, hologramLocation);
for (val nobodyLine : nobodyLines) {
hologram.appendTextLine(nobodyLine.replace("$position", String.valueOf(position)));
}
} else {
val cmiHologram = new CMIHologram("NextEconomy" + position, hologramLocation);
for (val nobodyLine : nobodyLines) {
cmiHologram.addLine(nobodyLine.replace("$position", String.valueOf(position)));
}
CMI.getInstance().getHologramManager().addHologram(cmiHologram);
cmiHologram.update();
HOLOGRAMS.add("NextEconomy" + position);
}
}
} else {
if (!hologramLines.isEmpty()) {
val group = plugin.getGroupWrapperManager().getGroup(account.getUsername());
val format = account.getBalanceFormated();
val hologramLocation = location.clone().add(0, height, 0);
if (holographicDisplays) {
val hologram = HologramsAPI.createHologram(plugin, hologramLocation);
for (val hologramLine : hologramLines) {
hologram.appendTextLine(hologramLine.replace("$position", String.valueOf(position)).replace("$player", account.getUsername()).replace("$prefix", group.getPrefix()).replace("$suffix", group.getSuffix()).replace("$amount", format));
}
} else {
val cmiHologram = new CMIHologram("NextEconomy" + position, hologramLocation);
for (val hologramLine : hologramLines) {
cmiHologram.addLine(hologramLine.replace("$position", String.valueOf(position)).replace("$player", account.getUsername()).replace("$prefix", group.getPrefix()).replace("$suffix", group.getSuffix()).replace("$amount", format));
}
CMI.getInstance().getHologramManager().addHologram(cmiHologram);
cmiHologram.update();
HOLOGRAMS.add("NextEconomy" + position);
}
}
}
val stand = location.getWorld().spawn(location, ArmorStand.class);
// show only after configuration
stand.setVisible(false);
stand.setMetadata("nexteconomy", new FixedMetadataValue(plugin, true));
stand.setSmall(small);
stand.setCustomNameVisible(false);
stand.setGravity(false);
stand.setArms(true);
val swordNumber = Math.min(SWORDS.length, position);
val sword = SWORDS[swordNumber - 1];
stand.setItemInHand(new ItemStack(sword));
val skinName = account == null ? "Yuhtin" : account.getUsername();
stand.setHelmet(new ItemBuilder(skinName).wrap());
stand.setChestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE, ColorUtil.getBukkitColorByHex(RankingValue.get(RankingValue::chestplateRGB))).wrap());
stand.setLeggings(new ItemBuilder(Material.LEATHER_LEGGINGS, ColorUtil.getBukkitColorByHex(RankingValue.get(RankingValue::leggingsRGB))).wrap());
stand.setBoots(new ItemBuilder(Material.LEATHER_BOOTS, ColorUtil.getBukkitColorByHex(RankingValue.get(RankingValue::bootsRGB))).wrap());
// configuration finished, show stand
stand.setVisible(true);
STANDS.add(stand);
}
}
use of com.nextplugins.economy.configuration.RankingValue in project NextEconomy by NextPlugins.
the class NPCRunnable method run.
@Override
public void run() {
clearPositions();
if (locationManager.getLocationMap().isEmpty())
return;
ArrayList<SimpleAccount> accounts = new ArrayList<>(rankingStorage.getRankByCoin().values());
val hologramLines = RankingValue.get(RankingValue::hologramArmorStandLines);
val nobodyLines = RankingValue.get(RankingValue::nobodyHologramLines);
for (val entry : locationManager.getLocationMap().entrySet()) {
val position = entry.getKey();
val location = entry.getValue();
if (location == null || location.getWorld() == null)
continue;
val chunk = location.getChunk();
if (!chunk.isLoaded())
chunk.load(true);
SimpleAccount account = position - 1 < accounts.size() ? accounts.get(position - 1) : null;
if (account == null) {
if (!nobodyLines.isEmpty()) {
val hologramLocation = location.clone().add(0, 3, 0);
if (holographicDisplays) {
val hologram = HologramsAPI.createHologram(plugin, hologramLocation);
for (val nobodyLine : nobodyLines) {
hologram.appendTextLine(nobodyLine.replace("$position", String.valueOf(position)));
}
} else {
val cmiHologram = new CMIHologram("NextEconomy" + position, hologramLocation);
for (val nobodyLine : nobodyLines) {
cmiHologram.addLine(nobodyLine.replace("$position", String.valueOf(position)));
}
CMI.getInstance().getHologramManager().addHologram(cmiHologram);
cmiHologram.update();
HOLOGRAMS.add("NextEconomy" + position);
}
}
} else {
if (!hologramLines.isEmpty()) {
val group = plugin.getGroupWrapperManager().getGroup(account.getUsername());
val format = account.getBalanceFormated();
val hologramLocation = location.clone().add(0, 3, 0);
if (holographicDisplays) {
val hologram = HologramsAPI.createHologram(plugin, hologramLocation);
for (val hologramLine : hologramLines) {
hologram.appendTextLine(hologramLine.replace("$position", String.valueOf(position)).replace("$player", account.getUsername()).replace("$prefix", group.getPrefix()).replace("$suffix", group.getSuffix()).replace("$amount", format));
}
} else {
val cmiHologram = new CMIHologram("NextEconomy" + position, hologramLocation);
for (val hologramLine : hologramLines) {
cmiHologram.addLine(hologramLine.replace("$position", String.valueOf(position)).replace("$player", account.getUsername()).replace("$prefix", group.getPrefix()).replace("$suffix", group.getSuffix()).replace("$amount", format));
}
CMI.getInstance().getHologramManager().addHologram(cmiHologram);
cmiHologram.update();
HOLOGRAMS.add("NextEconomy" + position);
}
}
}
val skinName = account == null ? "Yuhtin" : account.getUsername();
val profile = new Profile(skinName);
profile.complete();
profile.setName("");
profile.setUniqueId(new UUID(RANDOM.nextLong(), 0));
val npc = NPC.builder().profile(profile).location(location).imitatePlayer(false).lookAtPlayer(false).build(npcPool);
if (animation) {
val spawnAnimationRaw = AnimationValue.get(AnimationValue::spawnEmote);
executeAnimation(npc, spawnAnimationRaw);
}
}
}
use of com.nextplugins.economy.configuration.RankingValue in project NextEconomy by NextPlugins.
the class RankingView method createPageItems.
@Override
protected List<InventoryItemSupplier> createPageItems(PagedViewer viewer) {
val items = new ArrayList<InventoryItemSupplier>();
val headLore = RankingValue.get(RankingValue::inventoryModelHeadLore);
val tycoonTag = RankingValue.get(RankingValue::tycoonTagValue);
int position = 1;
val sorter = rankingSorterType.getOrDefault(viewer.getName(), -1);
Collection<SimpleAccount> rankingAccounts = sorter == -1 ? rankingStorage.getRankByCoin().values() : rankingStorage.getRankByMovimentation();
for (val account : rankingAccounts) {
int finalPosition = position;
items.add(() -> {
val name = account.getUsername();
val group = groupWrapperManager.getGroup(name);
val replacedDisplayName = (finalPosition == 1 ? RankingValue.get(RankingValue::inventoryModelHeadDisplayNameTop) : RankingValue.get(RankingValue::inventoryModelHeadDisplayName)).replace("$tycoon", tycoonTag).replace("$position", String.valueOf(finalPosition)).replace("$player", name).replace("$prefix", group.getPrefix()).replace("$suffix", group.getSuffix());
List<String> replacedLore = Lists.newArrayList();
val transactionName = account.getTransactionsQuantity() == 1 ? MessageValue.get(MessageValue::singularTransaction) : MessageValue.get(MessageValue::pluralTransaction);
for (val lore : headLore) {
replacedLore.add(lore.replace("$amount", account.getBalanceFormated()).replace("$transactions", account.getTransactionsQuantity() + " " + transactionName).replace("$movimentation", account.getMovimentedBalanceFormated()).replace("$position", String.valueOf(finalPosition)));
}
return InventoryItem.of(new ItemBuilder(account.getUsername()).name(replacedDisplayName).setLore(replacedLore).wrap());
});
position++;
}
return items;
}
use of com.nextplugins.economy.configuration.RankingValue in project NextEconomy by NextPlugins.
the class MoneyCommand method moneyTopCommand.
@Command(name = "coins.top", aliases = { "ranking", "podio" }, description = "Utilize para ver os jogadores com mais dinheiro do servidor.", async = true)
public void moneyTopCommand(Context<CommandSender> context) {
val rankingStorage = plugin.getRankingStorage();
val sender = context.getSender();
if (rankingStorage.updateRanking(false)) {
sender.sendMessage(ColorUtil.colored("&aAtualizando o ranking, aguarde alguns segundos."));
return;
}
val rankingType = RankingValue.get(RankingValue::rankingType);
if (rankingType.equalsIgnoreCase("CHAT")) {
val header = RankingValue.get(RankingValue::chatModelHeader);
val body = plugin.getRankingChatBody();
val footer = RankingValue.get(RankingValue::chatModelFooter);
header.forEach(sender::sendMessage);
sender.sendMessage(body.getMinecraftBodyLines());
footer.forEach(sender::sendMessage);
} else {
if (!(sender instanceof Player)) {
sender.sendMessage(ColorUtil.colored("&cEste tipo de ranking não é suportado via console."));
return;
}
val player = (Player) sender;
val rankingView = InventoryRegistry.getInstance().getRankingView();
rankingView.openInventory(player);
}
}
Aggregations