Help?

Discussion in 'Plugin Development' started by bob0310, Sep 7, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    bob0310

    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! :D
     
  2. Offline

    viper_monster

    Please Stop Writing In Caps Because It Is Harder To Read.
     
  3. Offline

    OcelotcR

    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.
     
  4. Offline

    bob0310

    OcelotcR, spoljo666

    Sorry, No im not using an array list im using the scoreboard features.
     
  5. Offline

    Lolmewn

    What have you tried?
     
  6. Offline

    bob0310

    Lolmewn

    I have tried these 2 thing.

    Code:java
    1. blue.addPlayer(player);
    2.  
    3. player.setScoreboard(blue);


    Here is my main class file:

    Code:java
    1. package me.dawson.callofminecrafttesting;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.Location;
    6. import org.bukkit.Material;
    7. import org.bukkit.block.Block;
    8. import org.bukkit.block.Sign;
    9. import org.bukkit.command.Command;
    10. import org.bukkit.command.CommandSender;
    11. import org.bukkit.enchantments.Enchantment;
    12. import org.bukkit.enchantments.EnchantmentWrapper;
    13. import org.bukkit.entity.Player;
    14. import org.bukkit.event.EventHandler;
    15. import org.bukkit.event.Listener;
    16. import org.bukkit.event.block.Action;
    17. import org.bukkit.event.player.PlayerEvent;
    18. import org.bukkit.event.player.PlayerInteractEvent;
    19. import org.bukkit.inventory.ItemStack;
    20. import org.bukkit.inventory.PlayerInventory;
    21. import org.bukkit.plugin.java.JavaPlugin;
    22. import org.bukkit.scoreboard.DisplaySlot;
    23. import org.bukkit.scoreboard.Objective;
    24. import org.bukkit.scoreboard.Scoreboard;
    25. import org.bukkit.scoreboard.ScoreboardManager;
    26. import org.bukkit.scoreboard.Team;
    27.  
    28. public class Call_Of_Minecraft_testing extends JavaPlugin implements Listener {
    29.  
    30. public void onEnable() {
    31. getServer().getPluginManager().registerEvents(this, this);
    32.  
    33. getLogger().info("Call Of Minecraft Is Working! YA!");
    34. ScoreboardManager sbmanager = Bukkit.getScoreboardManager();
    35. Scoreboard board = sbmanager.getNewScoreboard();
    36.  
    37. Team team1 = board.registerNewTeam("Red");
    38. Team team2 = board.registerNewTeam("Blue");
    39.  
    40. team1.setPrefix(ChatColor.RED + "");
    41. team2.setPrefix(ChatColor.BLUE + "");
    42.  
    43. team1.setAllowFriendlyFire(false);
    44. team2.setAllowFriendlyFire(false);
    45.  
    46. Objective obj = board.registerNewObjective("kills", "totalKillCount");
    47.  
    48. obj.setDisplaySlot(DisplaySlot.SIDEBAR);
    49. obj.setDisplayName("Team Kills");
    50.  
    51. for(Player player : Bukkit.getOnlinePlayers()) {
    52. player.setScoreboard(board);
    53. player.setScoreboard(sbmanager.getNewScoreboard());
    54. }
    55.  
    56. getConfig().options().copyDefaults(true);
    57. saveConfig();
    58. }
    59.  
    60. public void onDisable() {
    61. getLogger().info("Call Of Minecraft Is Off!");
    62.  
    63. }
    64.  
    65. @EventHandler
    66. public void onPlayerInteract(PlayerInteractEvent e) {
    67. Player player = e.getPlayer();
    68. if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
    69. Block b = e.getClickedBlock();
    70. if (b.getType() == Material.WALL_SIGN
    71. || b.getType() == Material.SIGN_POST) {
    72. Sign sign = (Sign) b.getState();
    73. String[] lines = sign.getLines();
    74.  
    75. if (lines[0].equalsIgnoreCase("[COMB]")) {
    76.  
    77. //blue.addPlayer(player);
    78. //player.setScoreboard(blue);
    79.  
    80. ItemStack food = new ItemStack(Material.COOKED_BEEF, 32);
    81. ItemStack gapple = new ItemStack(Material.GOLDEN_APPLE, 5);
    82. ItemStack arrow = new ItemStack(Material.ARROW, 1);
    83. ItemStack bow = new ItemStack(Material.BOW, 1);
    84. ItemStack cobble = new ItemStack(Material.COBBLESTONE, 64);
    85. ItemStack cobble2 = new ItemStack(Material.COBBLESTONE, 64);
    86. ItemStack cobble3 = new ItemStack(Material.COBBLESTONE, 32);
    87. ItemStack sword = new ItemStack(Material.DIAMOND_SWORD, 1);
    88. ItemStack helmet = new ItemStack(Material.LAPIS_BLOCK, 1);
    89. ItemStack chest = new ItemStack(
    90. Material.DIAMOND_CHESTPLATE, 1);
    91. ItemStack legs = new ItemStack(Material.DIAMOND_LEGGINGS, 1);
    92. ItemStack feet = new ItemStack(Material.DIAMOND_BOOTS, 1);
    93. bow.addEnchantment(Enchantment.ARROW_INFINITE, 1);
    94. bow.addEnchantment(Enchantment.DURABILITY, 3);
    95. chest.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL,
    96. 4);
    97. chest.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 4);
    98. chest.addEnchantment(Enchantment.DURABILITY, 3);
    99. legs.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4);
    100. legs.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 4);
    101. legs.addEnchantment(Enchantment.DURABILITY, 3);
    102. feet.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4);
    103. feet.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 4);
    104. feet.addEnchantment(Enchantment.DURABILITY, 3);
    105. sword.addEnchantment(Enchantment.DAMAGE_ALL, 3);
    106. sword.addEnchantment(Enchantment.DURABILITY, 3);
    107. PlayerInventory pi = /* Problom > */player.getInventory();
    108. pi.setItem(7, food);
    109. pi.setItem(2, gapple);
    110. pi.setHelmet(helmet);
    111. pi.setChestplate(chest);
    112. pi.setLeggings(legs);
    113. pi.setBoots(feet);
    114. pi.setItem(0, sword);
    115. pi.setItem(4, cobble);
    116. pi.setItem(5, cobble2);
    117. pi.setItem(6, cobble3);
    118. pi.setItem(1, bow);
    119. pi.setItem(3, arrow);
    120. player.teleport(new Location(Bukkit.getWorld(getConfig().getString("World")), getConfig().getLong("BTX"), getConfig().getLong("BTY"), getConfig().getLong("BTZ"), getConfig().getLong("BTD"), 0));
    121. }
    122.  
    123. else if (lines[0].equalsIgnoreCase("[COMR]")) {
    124.  
    125. ItemStack food = new ItemStack(Material.COOKED_BEEF, 32);
    126. ItemStack gapple = new ItemStack(Material.GOLDEN_APPLE, 5);
    127. ItemStack arrow = new ItemStack(Material.ARROW, 1);
    128. ItemStack bow = new ItemStack(Material.BOW, 1);
    129. ItemStack cobble = new ItemStack(Material.COBBLESTONE, 64);
    130. ItemStack cobble2 = new ItemStack(Material.COBBLESTONE, 64);
    131. ItemStack cobble3 = new ItemStack(Material.COBBLESTONE, 32);
    132. ItemStack sword = new ItemStack(Material.DIAMOND_SWORD, 1);
    133. ItemStack helmet = new ItemStack(Material.REDSTONE_BLOCK, 1);
    134. ItemStack chest = new ItemStack(
    135. Material.DIAMOND_CHESTPLATE, 1);
    136. ItemStack legs = new ItemStack(Material.DIAMOND_LEGGINGS, 1);
    137. ItemStack feet = new ItemStack(Material.DIAMOND_BOOTS, 1);
    138. bow.addEnchantment(Enchantment.ARROW_INFINITE, 1);
    139. bow.addEnchantment(Enchantment.DURABILITY, 3);
    140. chest.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL,
    141. 4);
    142. chest.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 4);
    143. chest.addEnchantment(Enchantment.DURABILITY, 3);
    144. legs.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4);
    145. legs.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 4);
    146. legs.addEnchantment(Enchantment.DURABILITY, 3);
    147. feet.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4);
    148. feet.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 4);
    149. feet.addEnchantment(Enchantment.DURABILITY, 3);
    150. sword.addEnchantment(Enchantment.DAMAGE_ALL, 3);
    151. sword.addEnchantment(Enchantment.DURABILITY, 3);
    152. PlayerInventory pi = /* Problom > */player.getInventory();
    153. pi.setItem(7, food);
    154. pi.setItem(2, gapple);
    155. pi.setHelmet(helmet);
    156. pi.setChestplate(chest);
    157. pi.setLeggings(legs);
    158. pi.setBoots(feet);
    159. pi.setItem(0, sword);
    160. pi.setItem(4, cobble);
    161. pi.setItem(5, cobble2);
    162. pi.setItem(6, cobble3);
    163. pi.setItem(1, bow);
    164. pi.setItem(3, arrow);
    165. player.teleport(new Location(Bukkit.getWorld(getConfig().getString("World")), getConfig().getLong("RTX"), getConfig().getLong("RTY"), getConfig().getLong("RTZ"), getConfig().getLong("RTD"), 0));
    166. }
    167. }
    168. }
    169. }
    170. }
    171.  
     
Thread Status:
Not open for further replies.

Share This Page