use of com.nextplugins.economy.configuration.AnimationValue 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.AnimationValue in project NextEconomy by NextPlugins.
the class NPCRunnable method onShowNPC.
@EventHandler
public void onShowNPC(PlayerNPCShowEvent event) {
if (animation) {
val emotes = AnimationValue.get(AnimationValue::showNpcEmotes);
val randomEmote = emotes.get(random.nextInt(emotes.size()));
val actionData = animationValue(randomEmote);
if (actionData != null) {
event.send(event.getNPC().labymod().queue(actionData.getLeft(), actionData.getRight()));
}
}
}
use of com.nextplugins.economy.configuration.AnimationValue 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);
}
}
}
Aggregations