How Can I Add A Player To A Team Sign When Right Clicked? I Got The Teams Setup And The Sign Listener But I Can't Figure Out How To Add Them To A Team When They Right Click The Sign. Thanks In Advance!
Yeh dont write in caps. When the listener event is called do Code: Player p = event.getPlayer(); Team1.put(p) Assuming you are using arraylists.
Lolmewn I have tried these 2 thing. Code:java blue.addPlayer(player); player.setScoreboard(blue); Here is my main class file: Code:java package me.dawson.callofminecrafttesting; import org.bukkit.Bukkit;import org.bukkit.ChatColor;import org.bukkit.Location;import org.bukkit.Material;import org.bukkit.block.Block;import org.bukkit.block.Sign;import org.bukkit.command.Command;import org.bukkit.command.CommandSender;import org.bukkit.enchantments.Enchantment;import org.bukkit.enchantments.EnchantmentWrapper;import org.bukkit.entity.Player;import org.bukkit.event.EventHandler;import org.bukkit.event.Listener;import org.bukkit.event.block.Action;import org.bukkit.event.player.PlayerEvent;import org.bukkit.event.player.PlayerInteractEvent;import org.bukkit.inventory.ItemStack;import org.bukkit.inventory.PlayerInventory;import org.bukkit.plugin.java.JavaPlugin;import org.bukkit.scoreboard.DisplaySlot;import org.bukkit.scoreboard.Objective;import org.bukkit.scoreboard.Scoreboard;import org.bukkit.scoreboard.ScoreboardManager;import org.bukkit.scoreboard.Team; public class Call_Of_Minecraft_testing extends JavaPlugin implements Listener { public void onEnable() { getServer().getPluginManager().registerEvents(this, this); getLogger().info("Call Of Minecraft Is Working! YA!"); ScoreboardManager sbmanager = Bukkit.getScoreboardManager(); Scoreboard board = sbmanager.getNewScoreboard(); Team team1 = board.registerNewTeam("Red"); Team team2 = board.registerNewTeam("Blue"); team1.setPrefix(ChatColor.RED + ""); team2.setPrefix(ChatColor.BLUE + ""); team1.setAllowFriendlyFire(false); team2.setAllowFriendlyFire(false); Objective obj = board.registerNewObjective("kills", "totalKillCount"); obj.setDisplaySlot(DisplaySlot.SIDEBAR); obj.setDisplayName("Team Kills"); for(Player player : Bukkit.getOnlinePlayers()) { player.setScoreboard(board); player.setScoreboard(sbmanager.getNewScoreboard()); } getConfig().options().copyDefaults(true); saveConfig(); } public void onDisable() { getLogger().info("Call Of Minecraft Is Off!"); } @EventHandler public void onPlayerInteract(PlayerInteractEvent e) { Player player = e.getPlayer(); if (e.getAction() == Action.RIGHT_CLICK_BLOCK) { Block b = e.getClickedBlock(); if (b.getType() == Material.WALL_SIGN || b.getType() == Material.SIGN_POST) { Sign sign = (Sign) b.getState(); String[] lines = sign.getLines(); if (lines[0].equalsIgnoreCase("[COMB]")) { //blue.addPlayer(player); //player.setScoreboard(blue); ItemStack food = new ItemStack(Material.COOKED_BEEF, 32); ItemStack gapple = new ItemStack(Material.GOLDEN_APPLE, 5); ItemStack arrow = new ItemStack(Material.ARROW, 1); ItemStack bow = new ItemStack(Material.BOW, 1); ItemStack cobble = new ItemStack(Material.COBBLESTONE, 64); ItemStack cobble2 = new ItemStack(Material.COBBLESTONE, 64); ItemStack cobble3 = new ItemStack(Material.COBBLESTONE, 32); ItemStack sword = new ItemStack(Material.DIAMOND_SWORD, 1); ItemStack helmet = new ItemStack(Material.LAPIS_BLOCK, 1); ItemStack chest = new ItemStack( Material.DIAMOND_CHESTPLATE, 1); ItemStack legs = new ItemStack(Material.DIAMOND_LEGGINGS, 1); ItemStack feet = new ItemStack(Material.DIAMOND_BOOTS, 1); bow.addEnchantment(Enchantment.ARROW_INFINITE, 1); bow.addEnchantment(Enchantment.DURABILITY, 3); chest.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4); chest.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 4); chest.addEnchantment(Enchantment.DURABILITY, 3); legs.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4); legs.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 4); legs.addEnchantment(Enchantment.DURABILITY, 3); feet.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4); feet.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 4); feet.addEnchantment(Enchantment.DURABILITY, 3); sword.addEnchantment(Enchantment.DAMAGE_ALL, 3); sword.addEnchantment(Enchantment.DURABILITY, 3); PlayerInventory pi = /* Problom > */player.getInventory(); pi.setItem(7, food); pi.setItem(2, gapple); pi.setHelmet(helmet); pi.setChestplate(chest); pi.setLeggings(legs); pi.setBoots(feet); pi.setItem(0, sword); pi.setItem(4, cobble); pi.setItem(5, cobble2); pi.setItem(6, cobble3); pi.setItem(1, bow); pi.setItem(3, arrow); player.teleport(new Location(Bukkit.getWorld(getConfig().getString("World")), getConfig().getLong("BTX"), getConfig().getLong("BTY"), getConfig().getLong("BTZ"), getConfig().getLong("BTD"), 0)); } else if (lines[0].equalsIgnoreCase("[COMR]")) { ItemStack food = new ItemStack(Material.COOKED_BEEF, 32); ItemStack gapple = new ItemStack(Material.GOLDEN_APPLE, 5); ItemStack arrow = new ItemStack(Material.ARROW, 1); ItemStack bow = new ItemStack(Material.BOW, 1); ItemStack cobble = new ItemStack(Material.COBBLESTONE, 64); ItemStack cobble2 = new ItemStack(Material.COBBLESTONE, 64); ItemStack cobble3 = new ItemStack(Material.COBBLESTONE, 32); ItemStack sword = new ItemStack(Material.DIAMOND_SWORD, 1); ItemStack helmet = new ItemStack(Material.REDSTONE_BLOCK, 1); ItemStack chest = new ItemStack( Material.DIAMOND_CHESTPLATE, 1); ItemStack legs = new ItemStack(Material.DIAMOND_LEGGINGS, 1); ItemStack feet = new ItemStack(Material.DIAMOND_BOOTS, 1); bow.addEnchantment(Enchantment.ARROW_INFINITE, 1); bow.addEnchantment(Enchantment.DURABILITY, 3); chest.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4); chest.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 4); chest.addEnchantment(Enchantment.DURABILITY, 3); legs.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4); legs.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 4); legs.addEnchantment(Enchantment.DURABILITY, 3); feet.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4); feet.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 4); feet.addEnchantment(Enchantment.DURABILITY, 3); sword.addEnchantment(Enchantment.DAMAGE_ALL, 3); sword.addEnchantment(Enchantment.DURABILITY, 3); PlayerInventory pi = /* Problom > */player.getInventory(); pi.setItem(7, food); pi.setItem(2, gapple); pi.setHelmet(helmet); pi.setChestplate(chest); pi.setLeggings(legs); pi.setBoots(feet); pi.setItem(0, sword); pi.setItem(4, cobble); pi.setItem(5, cobble2); pi.setItem(6, cobble3); pi.setItem(1, bow); pi.setItem(3, arrow); player.teleport(new Location(Bukkit.getWorld(getConfig().getString("World")), getConfig().getLong("RTX"), getConfig().getLong("RTY"), getConfig().getLong("RTZ"), getConfig().getLong("RTD"), 0)); } } } }}