Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » help me!(I doing a meny plugin but does not work :cry: )
help me! [message #1729648] Sat, 16 April 2016 22:21
viktor Degerman is currently offline viktor DegermanFriend
Messages: 1
Registered: April 2016
Junior Member
package com.bcbrozbukkit.youtube;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
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;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.event.block.Action;
import org.bukkit.event.inventory.InventoryClickEvent;




public class InventoryGUI extends JavaPlugin implements Listener{

public void onEnable() {
getServer().getPluginManager().registerEvents(this, this);

}

public void onDisable(){

}

public void teleportInWord(Player player, int x, int y, int z) {
player.teleport(new Location(player.getWorld(), z, y, z));
}
private void openGUI (Player player) {
Inventory inv = Bukkit.createInventory(null, 27, ChatColor.DARK_AQUA + "Endlezz transfer");

ItemStack ffa = new ItemStack (Material.BOW);
ItemMeta ffaMeta = ffa.getItemMeta();
ItemStack Unranked = new ItemStack(Material.IRON_SWORD);
ItemMeta UnrankedMeta = Unranked.getItemMeta();
ItemStack Ranked = new ItemStack(Material.DIAMOND_SWORD);
ItemMeta RankedMeta = Ranked.getItemMeta();
ItemStack Blue = new ItemStack(Material.STAINED_GLASS_PANE,3);
ItemMeta BlueMeta = Blue.getItemMeta();

ffaMeta.setDisplayName(ChatColor.AQUA + "Free 4 All");
((ItemStack) ffaMeta).setItemMeta(ffaMeta);

UnrankedMeta.setDisplayName(ChatColor.WHITE + "Unranked §b 1v1");
((ItemStack) UnrankedMeta).setItemMeta(UnrankedMeta);

RankedMeta.setDisplayName(ChatColor.AQUA + "anked §f1v1");
((ItemStack) RankedMeta).setItemMeta(RankedMeta);

BlueMeta.setDisplayName(null);
((ItemStack) BlueMeta).setItemMeta(BlueMeta);



inv.setItem(11, ffa);
inv.setItem(13, Unranked );
inv.setItem(15, Ranked);
inv.setItem(1, Blue);
inv.setItem(2, Blue);
inv.setItem(3, Blue);
inv.setItem(4, Blue);
inv.setItem(5, Blue);
inv.setItem(6, Blue);
inv.setItem(7, Blue);
inv.setItem(8, Blue);
inv.setItem(9, Blue);



player.openInventory(inv);
}


public void onInventoryClick(InventoryClickEvent event) {
if(!ChatColor.stripColor(event.getInventory().getName())
.equalsIgnoreCase("Server Selector"))
return;
Player player = (Player) event.getWhoClicked();
event.setCancelled(true);

if(event.getCurrentItem()==null || event.getCurrentItem().getType()==Material.AIR||event.getCurrentItem().hasItemMeta()) {
player.closeInventory();
return;
}

//stop!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

switch(event.getCurrentItem().getType()) {
case IRON_SWORD:
teleportInWord(player, 0, 50, 0);
player.closeInventory();
player.sendMessage(String.format("%sTeleported To %sSurvival!%s", ChatColor.GOLD,ChatColor.DARK_RED));
break;
case BOW:
teleportInWord(player, 3, 52, 1);
player.closeInventory();
player.sendMessage(String.format("%sTeleported To %sSurvival!%s", ChatColor.GOLD,ChatColor.DARK_RED));
break;
default:
break;
}
}

@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
event.getPlayer().getInventory()
.addItem(new ItemStack(Material.COMPASS));
}
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event){
Action a = event.getAction();
ItemStack is = event.getItem();

if(a == Action.PHYSICAL || is == null || is.getType()==Material.AIR)
return;
if(is.getType() == Material.COMPASS)
openGUI(event.getPlayer());
}

@Override
public boolean onCommand(CommandSender arg0, Command arg1, String arg2, String[] arg3) {
// TODO Auto-generated method stub
return false;



}
}


my plugin.yml
main: com.bcbrozbukkit.youtube.InventoryGUI
version: 1.0
name: InventoryGUI
Previous Topic:fix product export for macos in maven build
Next Topic:How to store global preferences at project level
Goto Forum:
  


Current Time: Tue Sep 25 00:08:05 GMT 2018

Powered by FUDForum. Page generated in 0.01986 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top