Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ru.Listeners;
- import org.bukkit.Sound;
- import org.bukkit.entity.ArmorStand;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.player.PlayerInteractAtEntityEvent;
- import org.bukkit.metadata.FixedMetadataValue;
- import org.bukkit.metadata.MetadataValue;
- import org.bukkit.plugin.Plugin;
- import ru.Config;
- import ru.EasterEggs;
- import ru.FeatherBoard;
- public class ArmorStandi implements Listener {
- @EventHandler
- public void onArmorStandInteract(PlayerInteractAtEntityEvent e) {
- if (e.getPlayer().hasPermission("eastereggs.default")) {
- String prefix = Config.getConfig().getString("Prefix").replace("&", "§");
- EasterEggs.setupEconomy();
- int cooldownTime = 1;
- Player player = e.getPlayer();
- if (player.hasMetadata("EasterEggs")) {
- for (MetadataValue value : player.getMetadata("EasterEggs")) {
- if (((FixedMetadataValue) value).asString().equalsIgnoreCase("ArmorStandMode")) {
- player.removeMetadata("EasterEggs", EasterEggs.getPlugin());
- EasterEggs.mode = false;
- String name = ((ArmorStand) e.getRightClicked()).getName();
- int x = ((ArmorStand) e.getRightClicked()).getLocation().getBlockX();
- int y = ((ArmorStand) e.getRightClicked()).getLocation().getBlockY();
- int z = ((ArmorStand) e.getRightClicked()).getLocation().getBlockZ();
- try {
- if (Config.getPresentsConfig().isConfigurationSection("ArmorStand")) {
- for (String number : Config.getPresentsConfig().getConfigurationSection("ArmorStand").getKeys(false)) {
- int x1 = Config.getPresentsConfig().getInt("ArmorStand." + Integer.valueOf(number) + ".locX");
- int y1 = Config.getPresentsConfig().getInt("ArmorStand." + Integer.valueOf(number) + ".locY");
- int z1 = Config.getPresentsConfig().getInt("ArmorStand." + Integer.valueOf(number) + ".locZ");
- if (x == x1 && y == y1 && z == z1) {
- player.sendMessage(prefix + Config.getConfig().getString("ArmorStand_already_set").replace("%name%", name).replace("%x%", String.valueOf(x)).replace("%y%", String.valueOf(y)).replace("%z%", String.valueOf(z)).replaceAll("&", "§"));
- return;
- }
- }
- }
- e.getPlayer().sendMessage(prefix + "§dArmorStand §a'§e" + name + "§a'§d сохранен!!");
- Config.getPresentsConfig().set("ArmorStand." + EasterEggs.onumber + ".name", name);
- Config.getPresentsConfig().set("ArmorStand." + EasterEggs.onumber + ".locX", x);
- Config.getPresentsConfig().set("ArmorStand." + EasterEggs.onumber + ".locY", y);
- Config.getPresentsConfig().set("ArmorStand." + EasterEggs.onumber + ".locZ", z);
- Config.getPresentsConfig().set("ArmorStand." + EasterEggs.onumber + ".messages", EasterEggs.messages.toArray(new String[EasterEggs.messages.size()]));
- Config.getPresentsConfig().set("ArmorStand." + EasterEggs.onumber + ".commands", EasterEggs.plugin.commands);
- Config.getPresentsConfig().set("ArmorStand." + EasterEggs.onumber + ".money", 100);
- Config.getPresentsConfig().set("ArmorStand." + EasterEggs.onumber + ".sounds.LEVEL_UP.volume", 1.0);
- Config.getPresentsConfig().set("ArmorStand." + EasterEggs.onumber + ".sounds.LEVEL_UP.pitch", 1.0);
- EasterEggs.onumber++;
- Config.presents.save(Config.presentsf);
- } catch (Exception ea) {
- return;
- }
- }
- }
- } else {
- try {
- int x = ((ArmorStand) e.getRightClicked()).getLocation().getBlockX();
- int y = ((ArmorStand) e.getRightClicked()).getLocation().getBlockY();
- int z = ((ArmorStand) e.getRightClicked()).getLocation().getBlockZ();
- player.sendMessage("1"); // Аля дебаг
- if (Config.getPresentsConfig().isConfigurationSection("ArmorStand")) {
- player.sendMessage("2"); // Аля дебаг
- for (String number : Config.getPresentsConfig().getConfigurationSection("ArmorStand").getKeys(false)) {
- player.sendMessage("3"); // Аля дебаг
- int x1 = Config.getPresentsConfig().getInt("ArmorStand." + Integer.valueOf(number) + ".locX");
- int y1 = Config.getPresentsConfig().getInt("ArmorStand." + Integer.valueOf(number) + ".locY");
- int z1 = Config.getPresentsConfig().getInt("ArmorStand." + Integer.valueOf(number) + ".locZ");
- if (x == x1 && y == y1 && z == z1 && !Config.getUsersConfig().getBoolean(player.getName() + ".ArmorStand." + Integer.valueOf(number))) {
- player.sendMessage("4"); // Аля дебаг
- int money = Config.getPresentsConfig().getInt("ArmorStand." + Integer.valueOf(number) + ".money");
- if (!Config.getUsersConfig().getBoolean(e.getPlayer().getName() + ".ArmorStand." + Integer.valueOf(number))) {
- player.sendMessage("5"); // Аля дебаг
- Config.getUsersConfig().set(e.getPlayer().getName() + ".ArmorStand." + Integer.valueOf(number), true);
- EasterEggs.economy.depositPlayer(e.getPlayer().getName(), money); //depositPlayer - выдать | withdrawPlayer - снять
- for (final String message : Config.getPresentsConfig().getStringList("ArmorStand." + Integer.valueOf(number) + ".messages")) {
- player.sendMessage("6"); // Аля дебаг
- player.sendMessage(message. replace("&", "§").replace("%one%", String.valueOf(EasterEggs.One(e.getPlayer().getPlayer()))).replace("%all%", String.valueOf(EasterEggs.All(e.getPlayer().getPlayer()))));
- }
- for (final String s : Config.getPresentsConfig().getConfigurationSection("ArmorStand." + number + ".sounds").getKeys(false)) {
- player.sendMessage("7"); // Аля дебаг
- player.playSound(e.getRightClicked().getLocation(), Sound.valueOf(s), (float) Config.getPresentsConfig().getDouble("ArmorStand." + number + ".sounds." + s + ".volume"), (float) Config.getPresentsConfig().getDouble("ArmorStand." + number + ".sounds." + s + ".pitch"));
- }
- player.sendMessage("8"); // Аля дебаг
- FeatherBoard.place1();
- Config.users.save(Config.usersf);
- return;
- }
- }
- if (x == x1 && y == y1 && z == z1 && Config.getUsersConfig().getBoolean(player.getName() + ".ArmorStand." + Integer.valueOf(number))) {
- if (EasterEggs.cooldowns.containsKey(player.getName())) {
- long secondsLeft = ((EasterEggs.cooldowns.get(player.getName()) / 1000) + cooldownTime) - (System.currentTimeMillis() / 1000);
- if (secondsLeft > 0)
- return;
- }
- player.sendMessage(prefix + Config.getConfig().getString("Present_find").replace("&", "§"));
- EasterEggs.cooldowns.put(String.valueOf(player.getName()), System.currentTimeMillis());
- }
- }
- }
- } catch (Exception ea) {
- return;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement