Skocz do zawartości
  • 0

Pomocy fast :(


Ever

Pytanie

Witam, napisalem plugin na gui. Pisze ta komende i nic :/ Zanim bedzie hate od was za plugin podobny do kamilkime, wzorowalem sie na nim.

Main:

package me.hotangel2k17.drop;

import me.hotangel2k17.drop.Listenery;

import org.bukkit.Bukkit;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;

public class Main extends JavaPlugin{

	private static Main instance;
	
	@Override
	public void onEnable(){
		instance = this;
		System.out.println("Uruchamianie...");
		saveDefaultConfig();
		Bukkit.getPluginManager().registerEvents(new Listenery(), this);
		getCommand("drop").setExecutor(new Listenery());
	}
	
	@Override
	public void onDisable(){
		System.out.println("Wylaczanie...");
	}
	
	public static Main getInst(){
		return instance;
	}
}

Listenery:

package me.hotangel2k17.drop;

import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

public class Listenery implements Listener, CommandExecutor{
	
	Inventory inv;
	
	@Override
	public boolean onCommand(CommandSender sender, Command cmd, String l, String[] args) {
		if(cmd.getName().equalsIgnoreCase("drop")){
			inv = Bukkit.createInventory(null, 9, "§5§lTeleportation menu");{
				inv.setItem(0, blank);
				inv.setItem(1, blank);
				inv.setItem(2, ow);
				inv.setItem(3, blank);
				inv.setItem(4, nw);
				inv.setItem(5, blank);
				inv.setItem(6, ew);
				inv.setItem(7, blank);
				inv.setItem(8, blank);
			}
		}
		return false;
	}
	
	ItemStack compass = new ItemStack(Material.COMPASS, 1);{
		ItemMeta im = compass.getItemMeta();
		im.setDisplayName("§c§lTeleporter");
		compass.setItemMeta(im);
	}
	
	ItemStack ow = new ItemStack(Material.GRASS, 1);{
		ItemMeta im = ow.getItemMeta();
		im.setDisplayName("§a§lOverworld");
		ow.setItemMeta(im);
	}
	
	ItemStack nw = new ItemStack(Material.NETHERRACK, 1);{
		ItemMeta im = nw.getItemMeta();
		im.setDisplayName("§4§lNether");
		nw.setItemMeta(im);
	}
	
	ItemStack ew = new ItemStack(Material.ENDER_STONE, 1);{
		ItemMeta im = ew.getItemMeta();
		im.setDisplayName("§9§lEnd");
		ew.setItemMeta(im);
	}
	
	ItemStack blank = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 8);{
		ItemMeta im = blank.getItemMeta();
		im.setDisplayName(" ");
		blank.setItemMeta(im);
	}

	@EventHandler
	public void onClick(InventoryClickEvent e){
		Inventory i = e.getInventory();
		if(i == null){
			return;
		}
		if(i !=null){
			if(!i.getName().equals(inv.getTitle())){
				return;
			}
			if (e.getCurrentItem() == null){
				return;
			}
			else{
				if(e.getCurrentItem().getItemMeta() == null){
					return;
				}
			}
		}
		if(e.getWhoClicked() instanceof Player){
			Player p = (Player) e.getWhoClicked();
			if(e.getCurrentItem().getItemMeta() !=null){
				if(e.getCurrentItem().getItemMeta().getDisplayName().equals(ow.getItemMeta().getDisplayName())){
					p.teleport(new Location(Bukkit.getWorlds().get(0), 0, 100, 0));
					e.setCancelled(true);
					p.openInventory(e.getInventory());
				}
				if(e.getCurrentItem().getItemMeta().getDisplayName().equals(nw.getItemMeta().getDisplayName())){
					p.teleport(new Location(Bukkit.getWorlds().get(1), 0, 132, 0));
					e.setCancelled(true);
					p.openInventory(e.getInventory());
				}
				if(e.getCurrentItem().getItemMeta().getDisplayName().equals(ew.getItemMeta().getDisplayName())){
					p.teleport(new Location(Bukkit.getWorlds().get(2), 0, 100, 0));
					e.setCancelled(true);
					p.openInventory(e.getInventory());
				} else{
					e.setCancelled(true);
					p.openInventory(e.getInventory());
				}
			}
		}
	}
}

 

Odnośnik do komentarza
Udostępnij na innych stronach

7 odpowiedzi na to pytanie

Rekomendowane odpowiedzi

  • 0
	ItemStack ew = new ItemStack(Material.ENDER_STONE, 1);{
		ItemMeta im = ew.getItemMeta();
		im.setDisplayName("§9§lEnd");
		ew.setItemMeta(im);
	}

to popraw,

	@Override
	public boolean onCommand(CommandSender sender, Command cmd, String l, String[] args) {
		if(cmd.getName().equalsIgnoreCase("drop")){
			inv = Bukkit.createInventory(null, 9, "§5§lTeleportation menu");{
				inv.setItem(0, blank);
				inv.setItem(1, blank);
				inv.setItem(2, ow);
				inv.setItem(3, blank);
				inv.setItem(4, nw);
				inv.setItem(5, blank);
				inv.setItem(6, ew);
				inv.setItem(7, blank);
				inv.setItem(8, blank);
			}
		}
		return false;
	}

i to, no i dodaj Player#openInventory(inv);

Odnośnik do komentarza
Udostępnij na innych stronach

  • 0

Przepraszam za zly dzial, ale dalem nie dziala.

package me.hotangel2k17.drop;

import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

public class Listenery implements Listener, CommandExecutor{
	
	Inventory inv;
	
	@Override
	public boolean onCommand(CommandSender sender, Command cmd, String l, String[] args) {
		if(cmd.getName().equalsIgnoreCase("drop")){
			inv = Bukkit.createInventory(null, 9, "§5§lTeleportation menu");{
				inv.setItem(0, blank);
				inv.setItem(1, blank);
				inv.setItem(2, ow);
				inv.setItem(3, blank);
				inv.setItem(4, nw);
				inv.setItem(5, blank);
				inv.setItem(6, ew);
				inv.setItem(7, blank);
				inv.setItem(8, blank);
			}
		}
		return false;
	}
	ItemStack compass = new ItemStack(Material.COMPASS, 1);{
		ItemMeta im = compass.getItemMeta();
		im.setDisplayName("§c§lTeleporter");
		compass.setItemMeta(im);
	}
	
	ItemStack ow = new ItemStack(Material.GRASS, 1);{
		ItemMeta im = ow.getItemMeta();
		im.setDisplayName("§a§lOverworld");
		ow.setItemMeta(im);
	}
	
	ItemStack nw = new ItemStack(Material.NETHERRACK, 1);{
		ItemMeta im = nw.getItemMeta();
		im.setDisplayName("§4§lNether");
		nw.setItemMeta(im);
	}
	
	ItemStack ew = new ItemStack(Material.ENDER_STONE, 1);{
		ItemMeta im = ew.getItemMeta();
		im.setDisplayName("§9§lEnd");
		ew.setItemMeta(im);
	}
	
	ItemStack blank = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 8);{
		ItemMeta im = blank.getItemMeta();
		im.setDisplayName(" ");
		blank.setItemMeta(im);
	}

	@EventHandler
	public void onClick(InventoryClickEvent e){
		Inventory i = e.getInventory();
		if(i == null){
			return;
		}
		if(i !=null){
			if(!i.getName().equals(inv.getTitle())){
				return;
			}
			if (e.getCurrentItem() == null){
				return;
			}
			else{
				if(e.getCurrentItem().getItemMeta() == null){
					return;
				}
			}
		}
		if(e.getWhoClicked() instanceof Player){
			Player p = (Player) e.getWhoClicked();
			p.openInventory(inv);
			if(e.getCurrentItem().getItemMeta() !=null){
				if(e.getCurrentItem().getItemMeta().getDisplayName().equals(ow.getItemMeta().getDisplayName())){
					p.teleport(new Location(Bukkit.getWorlds().get(0), 0, 100, 0));
					e.setCancelled(true);
					p.openInventory(e.getInventory());
				}
				if(e.getCurrentItem().getItemMeta().getDisplayName().equals(nw.getItemMeta().getDisplayName())){
					p.teleport(new Location(Bukkit.getWorlds().get(1), 0, 132, 0));
					e.setCancelled(true);
					p.openInventory(e.getInventory());
				}
				if(e.getCurrentItem().getItemMeta().getDisplayName().equals(ew.getItemMeta().getDisplayName())){
					p.teleport(new Location(Bukkit.getWorlds().get(2), 0, 100, 0));
					e.setCancelled(true);
					p.openInventory(e.getInventory());
				} else{
					e.setCancelled(true);
					p.openInventory(e.getInventory());
				}
			}
		}
	}
}

 

Odnośnik do komentarza
Udostępnij na innych stronach

Nieaktywny
Ten temat został zamknięty. Brak możliwości dodania odpowiedzi.
  • Ostatnio przeglądający   0 użytkowników

    • Brak zarejestrowanych użytkowników przeglądających tę stronę.
×
×
  • Dodaj nową pozycję...