Ir para conteúdo

Hurtty

Membros
  • Total de itens

    113
  • Registro em

  • Última visita

Respostas na Comunidade

  1. Hurtty's postagem in 2 Duvidas was marked as the answer   
    1. Delay

     

    Pra verificar se ele está com delay, usamos


            if (inCooldown(p.getName())) {
                // tem delay
                return;
            }

    Para setar o delay para o jogador, usamos


    addCooldown(p.getName(), 3);

    E aqui o código pra "manusear" o delay do jogador


    public static HashMap<String, Long> local = new HashMap<String, Long>();

    public static void addCooldown(String name, int cooldownSeconds) {
    local.put(name.toLowerCase(), System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(cooldownSeconds));
    }

    public static boolean inCooldown(String name) {
    return local.containsKey(name.toLowerCase()) && System.currentTimeMillis() < local.get(name.toLowerCase());
    }

    public static long getRemainingSeconds(String name) {
    if (!inCooldown(name))
    return 0;
    return TimeUnit.MILLISECONDS.toSeconds(local.get(name.toLowerCase()) - System.currentTimeMillis());
    }

    Lógico que tem códigos maiores mais que iriam facilitar muito, o delay está em segundos!

     

    2. "Item infinito"

     

    Código


    @SuppressWarnings("deprecation")
    public static void abrirInventarioPlayer(Player p) {

    Inventory inv = Bukkit.createInventory(null, 6 * 9, "Inventario Infinito");

    for (String key : Main.getInstance().getConfig().getConfigurationSection("Itens").getKeys(false)) {

    int id = Main.getInstance().getConfig().getInt("Itens." + key + ".ID");
    int slot = Main.getInstance().getConfig().getInt("Itens." + key + ".Slot");
    int quantia = Main.getInstance().getConfig().getInt("Itens." + key + ".Quantia");
    int data = Main.getInstance().getConfig().getInt("Itens." + key + ".Data");
    String nome = Main.getInstance().getConfig().getString("Itens." + key + ".Nome");
    List<String> lore = Main.getInstance().getConfig().getStringList("Itens." + key + ".Lore");

    ItemStack a = new ItemStack(Material.getMaterial(id), quantia, (short)data);
    ItemMeta b = a.getItemMeta();
    b.setDisplayName(nome);
    b.setLore(lore);
    a.setItemMeta(b);

    inv.setItem(slot, a);
    }

    p.openInventory(inv);
    }

    Como tem que ficar na config


    Itens:
    2:
    ID: 1
    Slot: 1
    Data: 0
    Nome: "&cItem 3"
    Lore:
    - 'fo'
    - 'da'
    - 'se'
    1:
    ID: 8
    Slot: 2
    Data: 0
    Nome: "&cItem 2"
    Lore:
    - 'fo'
    - 'da'
    - 'se'
    3:
    ID: 6
    Slot: 3
    Data: 0
    Nome: "&dItem 4"
    Lore:
    - 'fo'
    - 'da'
    - 'se'

    Espero que tenha ajudado

  2. Hurtty's postagem in Bota lapis lazuli no altar was marked as the answer   
    Quando abrir, auto incrementar o lapis


    @EventHandler
    public void InventoryOpenE(InventoryOpenEvent e) {
    if (e.getInventory() instanceof EnchantingInventory) {
    e.getInventory().setItem(1, new ItemStack(Material.INK_SACK);
    }
    }

    Cancelar que ele mova o lapis


    @EventHandler
    public void InventoryClickE(InventoryClickEvent e) {
    if (e.getClickedInventory() instanceof EnchantingInventory && e.getSlot() == 1) {
    e.setCancelled(true);
    }
    }

    Não testei

  3. Hurtty's postagem in [Entregue] Tablist plugin was marked as the answer   
    Recomendo HeroClanTags , você consegue mudar cor no tab , colocar o clan etc...
     
    Link> http://gamersboard.com.br/topic/116-heroclantags-12-%C2%BB-tags-de-clans-no-placar-e-no-tab/
×
×
  • Criar Novo...