use of com.nextplugins.economy.configuration.RankingValue in project NextEconomy by NextPlugins.
the class TopUpdateListener method onTopUpdate.
@EventHandler(priority = EventPriority.MONITOR)
public void onTopUpdate(AsyncMoneyTopPlayerChangedEvent event) {
if (event.isCancelled())
return;
if (AnimationValue.get(AnimationValue::enable)) {
val emotes = AnimationValue.get(AnimationValue::magnataEmotes);
val emote = emotes.get(RANDOM.nextInt(emotes.size()));
try {
val splittedValue = emote.split(":");
val labyModAction = LabyModModifier.LabyModAction.valueOf(splittedValue[0].toUpperCase());
val actionName = labyModAction.name().toLowerCase();
val actionId = Integer.parseInt(splittedValue[1]);
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "nexteconomy playanimation 1 " + actionName + " " + actionId);
} catch (Throwable throwable) {
NextEconomy.getInstance().getLogger().log(Level.SEVERE, "Magnata update animation value pattern malformed. (should be: \"sticker/emote:ID\")", throwable);
}
try {
val splittedValue = AnimationValue.get(AnimationValue::rageDance).split(":");
val labyModAction = LabyModModifier.LabyModAction.valueOf(splittedValue[0].toUpperCase());
val actionName = labyModAction.name().toLowerCase();
val actionId = Integer.parseInt(splittedValue[1]);
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "nexteconomy playanimation 2 " + actionName + " " + actionId);
} catch (Throwable throwable) {
NextEconomy.getInstance().getLogger().log(Level.SEVERE, "Rage animation value pattern malformed. (should be: \"sticker/emote:ID\")", throwable);
}
}
val username = event.getMoneyTop().getUsername();
if (MessageValue.get(MessageValue::enableMoneyTopMessage)) {
val title = MessageValue.get(MessageValue::moneyTopTitle).replace("$player", username);
val message = new ArrayList<String>();
for (val line : MessageValue.get(MessageValue::moneyTopMessage)) {
message.add(line.replace("$player", username).replace("$coins", event.getMoneyTop().getBalanceFormated()));
}
if (title.contains("<nl>")) {
val titlePackets = TitleUtils.buildTitlePackets(title, 20, 20, 20);
for (val onlinePlayer : Bukkit.getOnlinePlayers()) {
if (titlePackets == null) {
TitleUtils.sendTitle(onlinePlayer, title, 20, 20, 20);
} else {
TitleUtils.sendPacketsToPlayer(onlinePlayer, titlePackets);
}
for (val s : message) {
onlinePlayer.sendMessage(s);
}
}
}
}
for (String s : RankingValue.get(RankingValue::tycoonCommands)) {
Bukkit.getScheduler().runTask(NextEconomy.getInstance(), () -> Bukkit.dispatchCommand(Bukkit.getConsoleSender(), s.replace("$currentTycoon", username).replace("$lastTycoon", event.getLastMoneyTop().getUsername())));
}
}
use of com.nextplugins.economy.configuration.RankingValue in project NextEconomy by NextPlugins.
the class CustomRankingRegistry method register.
public void register() {
val pluginManager = Bukkit.getPluginManager();
String type = RankingValue.get(RankingValue::npcType);
if (type.equalsIgnoreCase("nothing")) {
plugin.getLogger().info("Cancelando registro de ranking por NPC, Holograma e ArmorStand, você desativou na ranking.yml.");
return;
}
if (!pluginManager.isPluginEnabled("CMI") && !pluginManager.isPluginEnabled("HolographicDisplays")) {
plugin.getLogger().log(Level.WARNING, "Dependência não encontrada ({0}) O ranking em NPC, Holograma e ArmorStand não serão usados.", "HolographicDisplays ou CMI");
return;
}
holographicDisplays = pluginManager.isPluginEnabled("HolographicDisplays");
boolean isNpc = type.equalsIgnoreCase("npc");
if (isNpc && !pluginManager.isPluginEnabled("ProtocolLib")) {
plugin.getLogger().log(Level.WARNING, "Dependência não encontrada ({0}) O ranking em NPC não será usado.", "ProtocolLib");
return;
}
LocationLoader.of(plugin, plugin.getLocationManager()).loadLocations();
if (isNpc)
runnable = new NPCRunnable(plugin, holographicDisplays);
else if (type.equalsIgnoreCase("armorstand"))
runnable = new ArmorStandRunnable(plugin, plugin.getLocationManager(), plugin.getRankingStorage(), holographicDisplays);
else
runnable = new HologramRunnable(plugin, plugin.getLocationManager(), plugin.getRankingStorage(), holographicDisplays);
enabled = true;
plugin.getLogger().info("Sistema de NPC e ArmorStand registrado com sucesso.");
}
use of com.nextplugins.economy.configuration.RankingValue in project NextEconomy by NextPlugins.
the class HologramRunnable method run.
@Override
public void run() {
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();
if (locationManager.getLocationMap().isEmpty())
return;
val accounts = rankingStorage.getRankByCoin();
val location = locationManager.getLocation(1);
if (location == null || location.getWorld() == null) {
plugin.getLogger().warning("A localização 1 do ranking é inválida.");
return;
}
val chunk = location.getChunk();
if (!chunk.isLoaded())
chunk.load(true);
val playerLines = playersLines(accounts.values());
val hologramLocation = location.clone().add(0, 5, 0);
if (holographicDisplays) {
val hologram = HologramsAPI.createHologram(plugin, hologramLocation);
for (val line : RankingValue.get(RankingValue::hologramDefaultLines)) {
if (line.equalsIgnoreCase("@players")) {
playerLines.forEach(hologram::appendTextLine);
} else
hologram.appendTextLine(line);
}
} else {
val cmiHologram = new CMIHologram("NextEconomy", hologramLocation);
for (val line : RankingValue.get(RankingValue::hologramDefaultLines)) {
if (line.equalsIgnoreCase("@players")) {
playerLines.forEach(cmiHologram::addLine);
} else
cmiHologram.addLine(line);
}
CMI.getInstance().getHologramManager().addHologram(cmiHologram);
cmiHologram.update();
HOLOGRAMS.add("NextEconomy");
}
}
use of com.nextplugins.economy.configuration.RankingValue in project NextEconomy by NextPlugins.
the class HologramRunnable method playersLines.
public List<String> playersLines(Collection<SimpleAccount> accounts) {
val lines = new ArrayList<String>();
val line = RankingValue.get(RankingValue::hologramDefaultLine);
var position = 1;
for (val account : accounts) {
if (position > RankingValue.get(RankingValue::hologramDefaultLimit))
break;
val group = plugin.getGroupWrapperManager().getGroup(account.getUsername());
lines.add(line.replace("$position", String.valueOf(position)).replace("$player", account.getUsername()).replace("$prefix", group.getPrefix()).replace("$suffix", group.getSuffix()).replace("$amount", account.getBalanceFormated()));
++position;
}
return lines;
}
use of com.nextplugins.economy.configuration.RankingValue in project NextEconomy by NextPlugins.
the class MoneyCommand method npcAddCommand.
@Command(name = "coins.npc.add", aliases = { "npc.adicionar" }, usage = "/coins npc add {posição}", description = "Utilize para definir uma localização de spawn de NPC de certa posição.", permission = "nexteconomy.command.npc.add", target = CommandTarget.PLAYER, async = true)
public void npcAddCommand(Context<Player> context, int position) throws IOException {
val player = context.getSender();
if (!CustomRankingRegistry.getInstance().isEnabled()) {
player.sendMessage(ChatColor.RED + "O ranking em NPC foi desabilitado por falta de dependências.");
return;
}
if (position <= 0) {
player.sendMessage(MessageValue.get(MessageValue::wrongPosition));
return;
}
val limit = RankingValue.get(RankingValue::rankingLimit);
if (position > limit) {
player.sendMessage(MessageValue.get(MessageValue::positionReachedLimit).replace("$limit", String.valueOf(limit)));
return;
}
if (locationManager.getLocationMap().containsKey(position)) {
player.sendMessage(MessageValue.get(MessageValue::positionAlreadyDefined));
return;
}
val location = player.getLocation();
// use center location (helping users xd)
location.setX(location.getBlockX() + .5);
location.setZ(location.getBlockZ() + .5);
locationManager.getLocationMap().put(position, location);
val locations = plugin.getNpcConfig().getStringList("npc.locations");
locations.add(position + " " + LocationUtil.byLocationNoBlock(location));
plugin.getNpcConfig().set("npc.locations", locations);
plugin.getNpcConfig().save(plugin.getNpcFile());
player.sendMessage(MessageValue.get(MessageValue::positionSuccessfulCreated).replace("$position", String.valueOf(position)));
CustomRankingRegistry.getInstance().getRunnable().run();
}
Aggregations