TagAPI - Change/color the name over people's heads!

Discussion in 'Resources' started by mbaxter, Sep 6, 2012.

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

    mbaxter ʇıʞʞnq ɐ sɐɥ ı

    Well, that's not doable. While TagAPI gives you the ability to customize names, Bukkit already provides full control over those for mobs. Though I thought that the set visible option made them visible at a substantial distance. Maybe that changed since the snapshots where I really played with it.
     
  2. Offline

    97WaterPolo

    mbaxter
    Sounds good, thank you so much for the information and for clarifying it!
     
  3. Offline

    Findbro

    Any updates on what can be expected for tagapi with 1.7.9+? seeing as mojang are reverting some of their recently skin features I didn't know if we could get player skins back?
     
  4. Offline

    mbaxter ʇıʞʞnq ɐ sɐɥ ı

    I'm hesitant to re-enable skins because users who are running 1.7.6-1.7.8 would get kicked if 1.7.9-valid packets were sent. I think I'm going to wait until CB 1.7.9 is out and then do it. :)
     
  5. Offline

    Syd

    mbaxter
    If you re-enable skins, would it be possible to make it toggleable for admins/devs? I would really like to keep the skins in some of my plugins.
     
  6. Offline

    mbaxter ʇıʞʞnq ɐ sɐɥ ı

    I'm hesitant to add features like that which will only really apply for one version of MC.
     
  7. Offline

    Findbro

    Okay thats fair, thanks for the update, I'll keep an eye out on github/dev.bukkit.org for updates, really didn't feel like having to use scoreboards
     


  8. Skip to 2 minutes 10 seconds xD It says "No more TagAPI".
     
  9. Offline

    Findbro

    Now that bukkit 1.7.9 is out you going to work on something with skins?
     
  10. Offline

    L33m4n123

    Not even remotly funny if you understand all they say D:
     
    KingFaris11 likes this.
  11. Offline

    mbaxter ʇıʞʞnq ɐ sɐɥ ı

    1.7.9 was not a mandatory client update. Allowing skins on 1.7.6-9 could potentially disconnect your players. I'm extremely hesitant to do that.
     
  12. Offline

    Squawkers13

    You could make that configurable, with a message that says to update to 1.7.9...

    EDIT: Wait, that may not be applicable...
     
  13. i have problem
    Code:java
    1. @EventHandler
    2. public void onNameTag(AsyncPlayerReceiveNameTagEvent event) {
    3. Player p = event.getPlayer();
    4. if (ArenaData.getArenaMode() == ArenaData.Modes.INGAME)
    5. if(ArenaData.Kupcy.contains(p.getName())){
    6. event.setTag(ChatColor.GREEN + event.getNamedPlayer().getName());
    7. p.setDisplayName(ChatColor.GREEN + p.getName());
    8. p.sendMessage("Jesteś Piratem!");
    9. TagAPI.refreshPlayer(p);


    this event doesnt work :C
     
  14. Offline

    jwa1

    Is it possible in this API or anywhere else to add another line to a player's nametag?
    Like this:
    jwa1
    [Somethinghere]
    If it is possible, how?​
    (Using 1.7.2 for now)
     
  15. jwa1 Scoreboards can display things below names.
     
  16. Offline

    mbaxter ʇıʞʞnq ɐ sɐɥ ı

    Doknesss Do not call the refresh method from inside the event unless you want to cause a loop. Please read the tutorial.

    jwa1 The only way you can modify below the name is the scoreboard API, setting an objective with the below-name display slot. This objective name will display the same below every name, and will have a number (score) with it.
     
  17. Offline

    GreatBlitz

    mbaxter
    Hi. I'm new to bukkit, so I just learnt how to include plugins using Maven.
    This is my main file:-
    Code:java
    1. package com.gmail.ablazethebest.TestPlugin;
    2.  
    3. import org.bukkit.Location;
    4. import org.bukkit.Material;
    5. import org.bukkit.World;
    6. import org.bukkit.command.Command;
    7. import org.bukkit.command.CommandSender;
    8. import org.bukkit.entity.Player;
    9. import org.bukkit.plugin.java.JavaPlugin;
    10.  
    11. public final class TestPlugin extends JavaPlugin {
    12.  
    13. int xAccess, yAccess, zAccess, xMaxAccess, zMaxAccess;
    14. boolean arenaExists = false;
    15. Arena arena = new Arena(this);
    16.  
    17. @Override
    18. public void onEnable() {
    19. getServer().getPluginManager().registerEvents(new MyEventListener(this),
    20. this);
    21. }
    22.  
    23. @Override
    24. public void onDisable() {
    25. getLogger().info("TestPlugin has been disabled.");
    26. }
    27.  
    28. @Override
    29. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
    30.  
    31. if ((cmd.getName()).equalsIgnoreCase("arenacreate")){
    32. arena.arenaCreate(args, sender);
    33. }
    34.  
    35. else if ((cmd.getName()).equalsIgnoreCase("arenajoin")){
    36. arena.arenaJoin(sender);
    37. }
    38.  
    39. else if((cmd.getName()).equalsIgnoreCase("dropachest")){
    40. Player player = (Player) sender;
    41. World world = player.getWorld();
    42. Location location = new Location(world, player.getLocation().getX(), player.getLocation().getY() + 20, player.getLocation().getZ());
    43. world.spawnFallingBlock(location, Material.CHEST, (byte) 0);
    44. }
    45. return false;
    46. }
    47. }
    48.  


    MyEventListener: (The TagAPI event is at the very bottom)
    Code:java
    1. package com.gmail.ablazethebest.TestPlugin;
    2.  
    3. import org.bukkit.ChatColor;
    4. import org.bukkit.Color;
    5. import org.bukkit.Material;
    6. import org.bukkit.Sound;
    7. import org.bukkit.block.Block;
    8. import org.bukkit.block.Chest;
    9. import org.bukkit.entity.FallingBlock;
    10. import org.bukkit.entity.Player;
    11. import org.bukkit.event.EventHandler;
    12. import org.bukkit.event.Listener;
    13. import org.bukkit.event.block.BlockPlaceEvent;
    14. import org.bukkit.event.entity.EntityChangeBlockEvent;
    15. import org.bukkit.inventory.Inventory;
    16. import org.bukkit.inventory.ItemStack;
    17. import org.bukkit.inventory.meta.LeatherArmorMeta;
    18. import org.kitteh.tag.AsyncPlayerReceiveNameTagEvent;
    19.  
    20. public final class MyEventListener implements Listener{
    21.  
    22. TestPlugin plugin;
    23. Arena arena = new Arena(plugin);
    24.  
    25. public MyEventListener(TestPlugin plugin){
    26. this.plugin = plugin;
    27. }
    28.  
    29. @EventHandler
    30. public void checkForTntAndEliminate(BlockPlaceEvent event){
    31. Block block = event.getBlockPlaced();
    32.  
    33.  
    34. if (block.getType() == Material.TNT){
    35. Block placeAgainst = event.getBlockAgainst();
    36. Material materialPlaceAgainst = placeAgainst.getType();
    37. Player player = event.getPlayer();
    38. ItemStack[] a = player.getInventory().getArmorContents();
    39. ItemStack helmet = a[3];
    40. LeatherArmorMeta lamh = (LeatherArmorMeta) helmet.getItemMeta();
    41. Color color = lamh.getColor();
    42. if ((color.asRGB() == Color.BLUE.asRGB()) && (materialPlaceAgainst == Material.DIAMOND_BLOCK)){
    43. player.sendMessage("You are not allowed to place TNT on the opposing team's field.");
    44. player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1, 1);
    45. block.setType(Material.AIR);
    46. }
    47.  
    48. else if ((color.asRGB() == Color.RED.asRGB()) && (materialPlaceAgainst == Material.EMERALD_BLOCK)){
    49. player.sendMessage("You are not allowed to place TNT on the opposing team's field.");
    50. player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1, 1);
    51. block.setType(Material.AIR);
    52. }
    53. }
    54. }
    55.  
    56. @EventHandler
    57. public void fallingChest(EntityChangeBlockEvent event){
    58. if (event.getEntity() instanceof FallingBlock){
    59. FallingBlock fb = (FallingBlock) event.getEntity();
    60. if (fb.getMaterial() == Material.CHEST){
    61. event.setCancelled(true);
    62. event.getBlock().setType(Material.CHEST);
    63. Chest chest = (Chest) event.getBlock().getState();
    64. Inventory inv = chest.getInventory();
    65. inv.addItem(new ItemStack(Material.WOOD));
    66. }
    67. }
    68. }
    69.  
    70. @EventHandler
    71. public void setTeamTag(AsyncPlayerReceiveNameTagEvent event){
    72. int team = arena.teamChecker(event.getNamedPlayer().getName());
    73. if (team == 1){
    74. event.setTag(ChatColor.BLUE + event.getNamedPlayer().getName());
    75. }
    76. else if (team == 2){
    77. event.setTag(ChatColor.RED + event.getNamedPlayer().getName());
    78. }
    79. }
    80.  
    81.  
    82. }
    83.  


    Arena.java:
    Code:java
    1. package com.gmail.ablazethebest.TestPlugin;
    2.  
    3. import java.util.HashMap;
    4. import java.util.Map;
    5. import org.bukkit.Color;
    6. import org.bukkit.DyeColor;
    7. import org.bukkit.Location;
    8. import org.bukkit.Material;
    9. import org.bukkit.Sound;
    10. import org.bukkit.World;
    11. import org.bukkit.block.Block;
    12. import org.bukkit.command.CommandSender;
    13. import org.bukkit.entity.Player;
    14. import org.bukkit.inventory.ItemStack;
    15. import org.bukkit.inventory.meta.LeatherArmorMeta;
    16. import org.bukkit.scheduler.BukkitTask;
    17.  
    18. public class Arena {
    19. boolean arenaExists = false;
    20. int xAccess, yAccess, zAccess, xMaxAccess, zMaxAccess;
    21. TestPlugin plugin;
    22. Map<String, Integer> map = new HashMap<String, Integer>();
    23. int currentTeam = 1;
    24.  
    25. public Arena(TestPlugin plugin){
    26. this.plugin = plugin;
    27. }
    28.  
    29. @SuppressWarnings("deprecation")
    30. public void arenaCreate(String[] args, CommandSender sender){
    31. setArenaExists(true);
    32. int x = Integer.parseInt(args[0]);
    33. int z = Integer.parseInt(args[1]);
    34. int xM = x + 20;
    35. int zM = z + 20;
    36. int y = Integer.parseInt(args[2]);
    37. setxAccess(x);
    38. setyAccess(y);
    39. setzAccess(z);
    40. setxMaxAccess(xM);
    41. setzMaxAccess(zM);
    42. Player player = (Player) sender;
    43. World world = player.getWorld();
    44. for (int a = x;a < xM;a++){
    45. for (int b = z;b < zM;b++){
    46. Block block = world.getBlockAt(a, y, b);
    47. block.setTypeIdAndData(35, DyeColor.RED.getData(), true);
    48. }
    49. }
    50.  
    51. for (int a = xM;a < (x + 40);a++){
    52. for (int b = z;b < zM;b++){
    53. Block block = world.getBlockAt(a, y, b);
    54. block.setTypeIdAndData(35, DyeColor.BLUE.getData(), true);
    55. }
    56. }
    57. }
    58.  
    59. public void arenaJoin(CommandSender sender){
    60. if (arenaExists){
    61. Player player = (Player) sender;
    62. World world = player.getWorld();
    63. if (currentTeam == 2){
    64. Location location = new Location(world, xAccess, yAccess, zAccess);
    65. player.sendMessage("You are in Red team!");
    66. player.playSound(player.getLocation(), Sound.FIRE, 1, 1);
    67. player.teleport(location);
    68. map.put(player.getName(), 1);
    69. currentTeam = 1;
    70. ItemStack a = new ItemStack(Material.LEATHER_HELMET);
    71. LeatherArmorMeta lama = (LeatherArmorMeta) a.getItemMeta();
    72. lama.setColor(Color.RED);
    73. a.setItemMeta(lama);
    74.  
    75. ItemStack b = new ItemStack(Material.LEATHER_CHESTPLATE);
    76. LeatherArmorMeta lamb = (LeatherArmorMeta) b.getItemMeta();
    77. lamb.setColor(Color.RED);
    78. b.setItemMeta(lamb);
    79.  
    80. ItemStack c = new ItemStack(Material.LEATHER_LEGGINGS);
    81. LeatherArmorMeta lamc = (LeatherArmorMeta) c.getItemMeta();
    82. lamc.setColor(Color.RED);
    83. c.setItemMeta(lamc);
    84.  
    85. ItemStack d = new ItemStack(Material.LEATHER_BOOTS);
    86. LeatherArmorMeta lamd = (LeatherArmorMeta) d.getItemMeta();
    87. lamd.setColor(Color.RED);
    88. d.setItemMeta(lamd);
    89.  
    90. ItemStack[] armorArrayRed = new ItemStack[4];
    91. armorArrayRed[0] = d;
    92. armorArrayRed[1] = c;
    93. armorArrayRed[2] = b;
    94. armorArrayRed[3] = a;
    95.  
    96. player.getInventory().setArmorContents(armorArrayRed);
    97. }
    98.  
    99. else if (currentTeam == 1){
    100. Location location = new Location(world, xMaxAccess, yAccess, zAccess);
    101. player.sendMessage("You are in Blue team!");
    102. player.teleport(location);
    103. map.put(player.getName(), 2);
    104. currentTeam = 2;
    105. player.playSound(player.getLocation(), Sound.WATER, 1, 1);
    106. ItemStack a = new ItemStack(Material.LEATHER_HELMET);
    107. LeatherArmorMeta lama = (LeatherArmorMeta) a.getItemMeta();
    108. lama.setColor(Color.BLUE);
    109. a.setItemMeta(lama);
    110.  
    111. ItemStack b = new ItemStack(Material.LEATHER_CHESTPLATE);
    112. LeatherArmorMeta lamb = (LeatherArmorMeta) b.getItemMeta();
    113. lamb.setColor(Color.BLUE);
    114. b.setItemMeta(lamb);
    115.  
    116. ItemStack c = new ItemStack(Material.LEATHER_LEGGINGS);
    117. LeatherArmorMeta lamc = (LeatherArmorMeta) c.getItemMeta();
    118. lamc.setColor(Color.BLUE);
    119. c.setItemMeta(lamc);
    120.  
    121. ItemStack d = new ItemStack(Material.LEATHER_BOOTS);
    122. LeatherArmorMeta lamd = (LeatherArmorMeta) d.getItemMeta();
    123. lamd.setColor(Color.BLUE);
    124. d.setItemMeta(lamd);
    125.  
    126. ItemStack[] armorArrayRed = new ItemStack[4];
    127. armorArrayRed[0] = d;
    128. armorArrayRed[1] = c;
    129. armorArrayRed[2] = b;
    130. armorArrayRed[3] = a;
    131.  
    132. player.getInventory().setArmorContents(armorArrayRed);
    133. }
    134.  
    135. BukkitTask task = new ChestDropper(this.plugin, 6, player).runTaskTimer(this.plugin, 100, 200);
    136. }
    137.  
    138. else{
    139. Player player = (Player) sender;
    140. player.sendMessage("No arena exists, sorry :(");
    141. }
    142. }
    143. public int getxAccess() {
    144. return xAccess;
    145. }
    146. public void setxAccess(int xAccess) {
    147. this.xAccess = xAccess;
    148. }
    149. public int getyAccess() {
    150. return yAccess;
    151. }
    152. public void setyAccess(int yAccess) {
    153. this.yAccess = yAccess;
    154. }
    155. public int getzAccess() {
    156. return zAccess;
    157. }
    158. public void setzAccess(int zAccess) {
    159. this.zAccess = zAccess;
    160. }
    161. public int getzMaxAccess() {
    162. return zMaxAccess;
    163. }
    164. public void setzMaxAccess(int zMaxAccess) {
    165. this.zMaxAccess = zMaxAccess;
    166. }
    167. public int getxMaxAccess() {
    168. return xMaxAccess;
    169. }
    170. public void setxMaxAccess(int xMaxAccess) {
    171. this.xMaxAccess = xMaxAccess;
    172. }
    173. public boolean isArenaExists() {
    174. return arenaExists;
    175. }
    176. public void setArenaExists(boolean arenaExists) {
    177. this.arenaExists = arenaExists;
    178. }
    179.  
    180. public int teamChecker(String player){
    181. int returnVal = map.get(player);
    182. return returnVal;
    183. }
    184. }
    185.  


    ChestDropper.java: (I don't think it has any relevance with the issue):
    Code:java
    1. package com.gmail.ablazethebest.TestPlugin;
    2.  
    3. import java.util.Random;
    4. import org.bukkit.Location;
    5. import org.bukkit.Material;
    6. import org.bukkit.entity.Player;
    7. import org.bukkit.scheduler.BukkitRunnable;
    8.  
    9. public class ChestDropper extends BukkitRunnable {
    10.  
    11. private TestPlugin plugin;
    12. int counter;
    13. Player player;
    14. boolean executedOnce;
    15. final int counterUnchanged = counter;
    16. int half = counterUnchanged / 2;
    17.  
    18. public ChestDropper(TestPlugin plugin, int counter, Player player){
    19. this.plugin = plugin;
    20. this.counter = counter;
    21. this.player = player;
    22. }
    23.  
    24. public boolean isEvenOrOdd(){
    25. if ((counter % 2) == 0){
    26. return true;
    27. }
    28. else{
    29. return false;
    30. }
    31. }
    32.  
    33.  
    34.  
    35. @Override
    36. public void run() {
    37. if (isEvenOrOdd()){
    38. if (counterUnchanged > half){
    39. Random rand = new Random();
    40. int x = plugin.xAccess;
    41. int y = plugin.yAccess;
    42. int z = plugin.zAccess;
    43. int xM = plugin.xMaxAccess;
    44. int zM = plugin.zMaxAccess;
    45. int xRand = rand.nextInt(xM - x) + x;
    46. int zRand = rand.nextInt(zM - z) + z;
    47. Location loca = new Location(player.getWorld(), xRand, y + 20, zRand);
    48. player.sendMessage("Deploying chest at " + xRand + ", " + y + ", " + zRand);
    49. player.getWorld().spawnFallingBlock(loca, Material.CHEST, (byte) 0);
    50. counter--;
    51. }
    52. else if (counterUnchanged <= half){
    53. Random rand = new Random();
    54. int x = plugin.xAccess;
    55. int y = plugin.yAccess;
    56. int z = plugin.zAccess;
    57. int xM = plugin.xMaxAccess;
    58. int zM = plugin.zMaxAccess;
    59. int xRand = rand.nextInt((xM + 20) - xM) + x;
    60. int zRand = rand.nextInt((zM + 20) - zM) + z;
    61. Location loca = new Location(player.getWorld(), xRand, y + 20, zRand);
    62. player.sendMessage("Deploying chest at " + xRand + ", " + y + ", " + zRand);
    63. player.getWorld().spawnFallingBlock(loca, Material.CHEST, (byte) 0);
    64. counter--;
    65. }
    66. else if (this.counter == 0){
    67. this.cancel();
    68. }
    69. }
    70.  
    71.  
    72. }
    73.  
    74. }
    75.  


    plugin.yml:
    Code:
    name: TestPlugin
    main: com.gmail.ablazethebest.TestPlugin.TestPlugin
    version: 1.0
    commands:
        arenacreate:
            description: Creates an arena.
            usage: /arenacreate <x> <z> <y>
            permission: TestPlugin.arenacreate
            permission-message: You don't have permission
        arenajoin:
            description: Joins an arena.
            usage: /arenajoin
            permission: TestPlugin.arenajoin
            permission-message: You don't have permission
           
        dropachest:
            description: Drops a chest on you.
            usage: /dropachest
            permission: TestPlugin.dropachest
            permission-message: You don't have permission
    depend: [TagAPI]
    pom.xml:
    Code:
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <groupId>com.gmail.ablazethebest</groupId>
      <artifactId>TestPlugin</artifactId>
      <version>0.0.1-SNAPSHOT</version>
      <build>
          <plugins>
              <plugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-compiler-plugin</artifactId>
                  <configuration>
                      <source>1.7</source>
                      <target>1.7</target>
                  </configuration>
              </plugin>
          </plugins>
      </build>
      <repositories>
          <repository>
              <id>bukkit-repo</id>
              <url>http://repo.bukkit.org/content/groups/public/</url>
          </repository>
          <repository>
              <id>kitteh-repo</id>
              <url>http://repo.kitteh.org/content/repositories/public/</url>
          </repository>
      </repositories>
        <dependencies>
          <dependency>
              <groupId>org.bukkit</groupId>
              <artifactId>bukkit</artifactId>
              <version>1.7.2-R0.3</version>
              <type>jar</type>
              <scope>provided</scope>
          </dependency>
          <dependency>
              <groupId>org.kitteh</groupId>
              <artifactId>tagapi</artifactId>
              <version>3.0</version>
              <type>jar</type>
              <scope>provided</scope>
          </dependency>
      </dependencies>
    </project>
    Now, I'm in blue team and my friend in red. None of us can see colored names! Can you help me out?
     
  18. Offline

    mbaxter ʇıʞʞnq ɐ sɐɥ ı

    GreatBlitz add some code to output to console what team you are in the name tag event. Also check your server log for errors.
     
  19. Offline

    GreatBlitz

    mbaxter
    I was running on my friend's server so I didn't notice this earlier:
    Code:
    [19:29:53 ERROR]: Could not load 'plugins\TestPlugin-0.0.1-SNAPSHOT.jar' in fold
    er 'plugins'
    org.bukkit.plugin.UnknownDependencyException: TagAPI
            at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager
    .java:201) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-50-gdce2b35-b3019jnks]
            at org.bukkit.craftbukkit.v1_7_R1.CraftServer.loadPlugins(CraftServer.ja
    va:350) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-50-gdce2b35-b3019jnks]
            at org.bukkit.craftbukkit.v1_7_R1.CraftServer.<init>(CraftServer.java:31
    2) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-50-gdce2b35-b3019jnks]
            at net.minecraft.server.v1_7_R1.PlayerList.<init>(PlayerList.java:63) [c
    raftbukkit.jar:git-Bukkit-1.7.2-R0.2-50-gdce2b35-b3019jnks]
            at net.minecraft.server.v1_7_R1.DedicatedPlayerList.<init>(SourceFile:14
    ) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-50-gdce2b35-b3019jnks]
            at net.minecraft.server.v1_7_R1.DedicatedServer.init(DedicatedServer.jav
    a:126) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-50-gdce2b35-b3019jnks]
            at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java
    :424) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-50-gdce2b35-b3019jnks]
            at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:6
    17) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-50-gdce2b35-b3019jnks]
    UnknownDependency. I told you I'm new to this dependency and Maven stuff. All this was just a blind attempt. I just looked at how craftbukkit does the pom.xml and I did something random albeit similar for TagAPI.

    #Cats4ever
     
  20. Offline

    mbaxter ʇıʞʞnq ɐ sɐɥ ı

    GreatBlitz It's doing that because you never put TagAPI on the server ;)
     
  21. Offline

    GreatBlitz

    mbaxter
    Hmm, I put that on the server. Solves that. But now whenever I look at an opposite team guy, I get this:-
    Code:
    [20:15:38] [Netty IO #2/ERROR]: Could not pass event AsyncPlayerReceiveNameTagEvent to TestPlugin v1.0
    org.bukkit.event.EventException
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:427) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:481) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:463) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at org.kitteh.tag.TagAPI.getName(TagAPI.java:302) [TagAPI.jar:?]
        at org.kitteh.tag.TagAPI.getNameForPacket20(TagAPI.java:380) [TagAPI.jar:?]
        at org.kitteh.tag.TagAPIHandler.getNameForPacket20(TagAPIHandler.java:40) [TagAPI.jar:?]
        at org.kitteh.tag.compat.v1_7_R1.DefaultHandler.handlePacket(DefaultHandler.java:48) [TagAPI.jar:?]
        at org.kitteh.tag.api.PacketHandlerNetty$TagAPIChannelOutboundHandler.write(PacketHandlerNetty.java:43) [TagAPI.jar:?]
        at net.minecraft.util.io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:644) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at net.minecraft.util.io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:698) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at net.minecraft.util.io.netty.channel.DefaultChannelHandlerContext.writeAndFlush(DefaultChannelHandlerContext.java:688) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at net.minecraft.util.io.netty.channel.DefaultChannelHandlerContext.writeAndFlush(DefaultChannelHandlerContext.java:717) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at net.minecraft.util.io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:893) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at net.minecraft.util.io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:239) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at net.minecraft.server.v1_7_R1.QueuedProtocolSwitch.run(SourceFile:133) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at net.minecraft.util.io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:354) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at net.minecraft.util.io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:348) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at net.minecraft.util.io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at java.lang.Thread.run(Unknown Source) [?:1.7.0_09]
    Caused by: java.lang.NullPointerException
        at com.gmail.ablazethebest.TestPlugin.Arena.teamChecker(Arena.java:181) ~[?:?]
        at com.gmail.ablazethebest.TestPlugin.MyEventListener.setTeamTag(MyEventListener.java:72) ~[?:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_09]
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_09]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_09]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_09]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:425) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        ... 19 more
    
    EDIT: NullPointerException hmm. I'll do a quick check on my code too. See if you can spot any bugs on the arena file?

    You're the best person ever :D
    #Cats4ever
     
  22. Offline

    mbaxter ʇıʞʞnq ɐ sɐɥ ı

    GreatBlitz That NPE is in your Arena class. Nothing to do with TagAPI ;)
     
  23. Offline

    GreatBlitz

    mbaxter
    Okay, so I did some research and I found out this - What if I look at a player who is in NO team? At that time I need to cancel the event! Is there no event.setCancelled() method?
     
  24. Offline

    mbaxter ʇıʞʞnq ɐ sɐɥ ı

    GreatBlitz
    Why do you need to cancel the event?
     
  25. Offline

    GreatBlitz

    mbaxter
    Lets just say I look at a player who isn't playing my minigame. As he isn't playing, he isn't in any team. In that case, the hashmap value for that player is null. In case the hashmap value is null, I don't want to color the nickname or do anything. How do I do that?

    Heyyyy maybe I can do event.setTag(event.getNamedPlayer().getName())? Setting the tag of the player to his name? Making no changes at all??
     
  26. Offline

    SniperFodder

    Or just return before the rest of the code runs since you aren't doing anything.
     
  27. Offline

    GreatBlitz

    So do something like
    if(teamChecker(player) == null) { return; }
    ?
    SniperFodder
     
  28. Offline

    mbaxter ʇıʞʞnq ɐ sɐɥ ı

    GreatBlitz Yeah. Just don't try setting the tag if you don't want it set by you.
     
  29. Offline

    GreatBlitz

    mbaxter
    Alright, thanks! I still seem to be having some problems, but they don't seem to have anything to do with TagAPI. Well, time to post the forums! ;)

    See ya Cat-lord!
     
    mbaxter likes this.
  30. Offline

    Squid_Boss

    mbaxter Hey there, I seem to be having an issue with skins. I am only changing the player's color and they're getting a steve skin. Here's the event :
    Code:java
    1. @EventHandler
    2. public void onPlayerTag(AsyncPlayerReceiveNameTagEvent e) throws Exception {
    3. Player p = e.getNamedPlayer();
    4. e.setTag(ChatColor.RED + p.getName());
    5. }


    Ignore the throws exception. :p

    Actually nevermind, I seemed to have missed the entire page before this. Carry on. Sorry to bother, yada yada yada.
     
Thread Status:
Not open for further replies.

Share This Page