Skocz do zawartości
  • 👋 Witaj na MPCForum!

    Przeglądasz forum jako gość, co oznacza, że wiele świetnych funkcji jest jeszcze przed Tobą! 😎

    • Pełny dostęp do działów i ukrytych treści
    • Możliwość pisania i odpowiadania w tematach
    • System prywatnych wiadomości
    • Zbieranie reputacji i rozwijanie swojego profilu
    • Członkostwo w jednej z największych społeczności graczy

    👉 Dołączenie zajmie Ci mniej niż minutę – a zyskasz znacznie więcej!

    Zarejestruj się teraz

Problem z InventoryClickEvent, własny plugin.


Pikselke

Rekomendowane odpowiedzi

Opublikowano

siemka!

znowu mam problem z 2 Klasami

 

Bo mam klasy:

Drop

InventoryClick

 

w InventoryClick:

public class InventoryClick implements Listener {
	
	public Inventory inv;
	
    @EventHandler
    public void onClick(final InventoryClickEvent e) {
        if (e.getInventory() == null) {
            return;
        }
        if (e.getCurrentItem() == null) {
            return;
        }
        if (e.getCurrentItem().getType().equals((Object)Material.AIR)) {
            return;
        }
        if (!e.getCurrentItem().hasItemMeta()) {
            return;
        }
        if (e.getInventory().getTitle() != null && e.getInventory().getTitle().equals("§c§lMenu Dropu!")) {
            if (e.getCurrentItem().getType() == Material.IRON_ORE) {
                e.setCancelled(true);
                    e.getWhoClicked().closeInventory();
                    e.getWhoClicked().openInventory(inv);
                    this.sendMSG("§8» §cOtworzyles drop.", e.getWhoClicked());
                }
                else {
                    e.getWhoClicked().closeInventory();
                    this.sendMSG("§8» §cOtworzyles drop", e.getWhoClicked());
                }
                return;
            }
            e.setCancelled(true);
            e.getWhoClicked().openInventory(e.getInventory());
        }
   
    
    public void sendMSG(final String msg, final HumanEntity humanEntity) {
        ((Player)humanEntity).sendMessage(msg);
    }
}


a w Drop:

public class Drop implements Listener, CommandExecutor {
	
	public Inventory inv;

	@Override
	public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
		if(cmd.getName().equalsIgnoreCase("drop")){
			Player p = (Player) sender;
            final Config cfg = Config.getInst();
        final User u = User.get(sender.getName());
        final Inventory inv1 = Bukkit.createInventory((InventoryHolder)null, 9, "§c§lMenu Dropu!");
        final ItemStack is1 = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short)DyeColor.GRAY.getData());
        final ItemMeta im = is1.getItemMeta();
        im.setDisplayName(" ");
        
        final ItemStack is2 = new ItemStack(Material.IRON_ORE, 1);
        final ItemMeta im2 = is2.getItemMeta();
        im2.setDisplayName("§c§lDROP ZE STONE!");
        
        final ItemStack is3 = new ItemStack(Material.EXP_BOTTLE, 1);
        final ItemMeta im3 = is3.getItemMeta();
        im3.setDisplayName("§c§lSKLEP ZA XP");
        
        is1.setItemMeta(im);
        is2.setItemMeta(im2);
        is3.setItemMeta(im3);
        inv1.setItem(0, is2);
        inv1.setItem(1, is3);
        inv1.setItem(7, turbodrop);
        inv1.setItem(8, stats);
        p.openInventory(inv1);
}
		return false;
	}

}

chce by jak sie kliknie w Inventory na Iron_ore to przenosi do ekwipunku z klasy DropCmd

            final Inventory inv = Bukkit.createInventory((InventoryHolder)null, 27, "§c§lDrop");

Mam daleko gdzieś takie komentarze:

kolejny programista:

itp:

dla mnie to nabijanie postów

 

                 EASYYT.PL

Opublikowano

Masz błąd == null musi być jeden znak równości

 

Widzę znasz się :v.

 

A co Ci wysypuje?

I po raz kolejny proszę.. NIE UŻYWAJCIE TYCH DEBILNYCH DEKOMPILATORÓW.

 

Nie rozumiem w ogóle Twojego kodu ;x Wygląda to jakbyś kopiował po kolei z każdego pluginu po troszkę..

this.sendMSG("§8» §cOtworzyles drop.", e.getWhoClicked());

Co to w ogóle jest?

    public void sendMSG(final String msg, final HumanEntity humanEntity) {
        ((Player)humanEntity).sendMessage(msg);
    }

A za to to powinni jaja ucinać przy samej dupie:

§

NIE UŻYWAMY TEGO -.-.

784091427630431250239.png

Regulamin sygnatur

Opublikowano

@OldisPL

 

 

Masz błąd == null musi być jeden znak równości

 

Widzę znasz się :v.

 

A co Ci wysypuje?

I po raz kolejny proszę.. NIE UŻYWAJCIE TYCH DEBILNYCH DEKOMPILATORÓW.

 

Nie rozumiem w ogóle Twojego kodu ;x Wygląda to jakbyś kopiował po kolei z każdego pluginu po troszkę..

this.sendMSG("§8» §cOtworzyles drop.", e.getWhoClicked());

Co to w ogóle jest?

    public void sendMSG(final String msg, final HumanEntity humanEntity) {
        ((Player)humanEntity).sendMessage(msg);
    }

A za to to powinni jaja ucinać przy samej dupie:

§

NIE UŻYWAMY TEGO -.-.

 

1.kod sam pisałem :D

2.Aha mam korzystać z ChatColor?

 

@Ceglikson

Aha

 

                 EASYYT.PL

Opublikowano

Zacznijmy od tego gdzie ty w ogóle menu tworzysz..?

I co to jest?

            else {
                e.getWhoClicked().closeInventory();
                this.sendMSG("§8» §cOtworzyles drop", e.getWhoClicked());
            }

Bo nie do końca czaję do czego to służy lel.

   @EventHandler
    public void onInventoryClickEvent(InventoryClickEvent e) {
        if (e.getInventory() == null) {
            return;
        }
        if (e.getCurrentItem() == null) {
            return;
        }
        if (e.getCurrentItem().getType().equals(Material.AIR)) {
            return;
        }
        if (!e.getCurrentItem().hasItemMeta()) {
            return;
        }
        if (e.getInventory().getName() == null) {
            return;
        }
        if (!e.getInventory().getName().equalsIgnoreCase(ChatColor.RED + "" + ChatColor.BOLD + "Menu Dropu!")) {
            return;
        }
        e.setCancelled(true);
        Player p = (Player)e.getWhoClicked();
        if (e.getCurrentItem().getType().equals(Material.IRON_ORE)){
            p.openInventory(inv);
            p.sendMessage(ChatColor.GREEN + "»" +ChatColor.RED + "Otworzyles drop,");
            return;
        }
        p.sendMessage("Koniec kodu, bledny wybor.");
    }

784091427630431250239.png

Regulamin sygnatur

Opublikowano

pomyliłem sie sorka

 

@OldisPL

 

ale ja mam Inventory Click w jednej klasie a Drop w innej i DropCommand w innej

wiec jak zrobie

p.openinventory(inv);

to będzie bład

 

                 EASYYT.PL

Opublikowano

@Pikselke

Polecam najpierw nauczyć się podstaw a potem pisać pluginy ;x..

 

Stwórz sobie w static menu w osobnej klasie np DropInventory z public static zmienną inventory a potem ją wywołaj ;x

784091427630431250239.png

Regulamin sygnatur

Opublikowano

Po prostu do otwierania inv robisz metode np.

public class Drop implements Listener, CommandExecutor {
 
public Inventory inv;
 
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if(cmd.getName().equalsIgnoreCase("drop")){
Player p = (Player) sender;
                Drop.openGUI(p);
}
return false;
}
public static void openGUI(Player p){
            final Config cfg = Config.getInst();
        final User u = User.get(sender.getName());
        final Inventory inv1 = Bukkit.createInventory((InventoryHolder)null, 9, "§c§lMenu Dropu!");
        final ItemStack is1 = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short)DyeColor.GRAY.getData());
        final ItemMeta im = is1.getItemMeta();
        im.setDisplayName(" ");
        
        final ItemStack is2 = new ItemStack(Material.IRON_ORE, 1);
        final ItemMeta im2 = is2.getItemMeta();
        im2.setDisplayName("§c§lDROP ZE STONE!");
        
        final ItemStack is3 = new ItemStack(Material.EXP_BOTTLE, 1);
        final ItemMeta im3 = is3.getItemMeta();
        im3.setDisplayName("§c§lSKLEP ZA XP");
        
        is1.setItemMeta(im);
        is2.setItemMeta(im2);
        is3.setItemMeta(im3);
        inv1.setItem(0, is2);
        inv1.setItem(1, is3);
        inv1.setItem(7, turbodrop);
        inv1.setItem(8, stats);
        p.openInventory(inv1);
}
}

A za otwieranie odpowiada

Drop.openGUI(Player);

Ps. mogłem się pomylić z { } ale chyba ogarniesz, gdzie dodac a gdzie usunąć. :)

Opublikowano

@TheMajsterPL

 

Dzieki! :D

do zamikniecia!

 

                 EASYYT.PL

Zarchiwizowany

Ten temat przebywa obecnie w archiwum. Dodawanie nowych odpowiedzi zostało zablokowane.

×
×
  • Dodaj nową pozycję...