Hi there, For my server I decided to make a Admin GUI menu so we can ban players trough that menu. I wanted to right-click a player with a playerhead and then open the menu for that player so you can only ban that player. The code for getting the playername is already done, but I don't know how to send the playername to my menu(not included here). Code for selecting the player: Code:java package me.Opgesnoven.admin; import me.Opgesnoven.sc.Main; import org.bukkit.Bukkit;import org.bukkit.Material;import org.bukkit.entity.Entity;import org.bukkit.entity.Player;import org.bukkit.event.EventHandler;import org.bukkit.event.Listener;import org.bukkit.event.player.PlayerInteractEntityEvent; public class PlayerMenu implements Listener {public Main plugin; public PlayerMenu(Main instance) { } @EventHandlerpublic void onInteract(PlayerInteractEntityEvent e) {Entity entity = e.getRightClicked();Player p = e.getPlayer(); if(e.getRightClicked() instanceof Player) {if(p.getItemInHand().getType().equals(Material.SKULL_ITEM)) {String name = ((Player) entity).getName();Bukkit.broadcastMessage("His name is: " + name);}}}} Please help me out! Jordy
I have no solution to your problem, but an idea would be to add permissions, therefore players aren't going to go around banning people...
Only ops will be able to use it ;-) Thats my question, am I able to do it one way or another? I dont think im the first one with this idea.
You could try: Code:java package me.Opgesnoven.admin; import me.Opgesnoven.sc.Main; import me.Opgesnoven.sc.NAMEOFCLASSWITHMENU //Import the class with your menu in import org.bukkit.Bukkit;import org.bukkit.Material;import org.bukkit.entity.Entity;import org.bukkit.entity.Player;import org.bukkit.event.EventHandler;import org.bukkit.event.Listener;import org.bukkit.event.player.PlayerInteractEntityEvent; public class PlayerMenu implements Listener {public Main plugin; public PlayerMenu(Main instance) { } @EventHandlerpublic void onInteract(PlayerInteractEntityEvent e) {Entity entity = e.getRightClicked();Player p = e.getPlayer(); if(e.getRightClicked() instanceof Player) {if(p.getItemInHand().getType().equals(Material.SKULL_ITEM)) {String name = p.getName();Bukkit.broadcastMessage("His name is: " + name);NAMEOFCLASSWITHMENU menu = new NAMEOFCLASSWITHMENU(name);menu.doStuff();}}}} Code:java package me.Opgesnoven.admin; private String player;public class NAMEOFCLASSWITHMENU{public NAMEOFCLASSWITHMENU(String name){player = name;}public doStuff(){//Inventory code here, using 'name' as the playername, for any lore/commands you need to do.}} I think... I can't really test to see if it works because I don't have other code. EDIT: I made a small edit to the code so it makes more sense.