Solved Automatic naming?

Discussion in 'Plugin Development' started by Deathkilla, Jun 13, 2017.

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

    Deathkilla

    Is it possible to use a bukkit runnable to check a players inventory ever 10 ticks and check for a sheer(s) then set that sheers name to so and so. This is what I came up with.

    Code:
    public class barbb extends JavaPlugin {
    
        public void onEnable(){
            BukkitScheduler scheduler = getServer().getScheduler();
               scheduler.scheduleSyncRepeatingTask(this, new Runnable() {
                   @Override
                   public void run() {
                      for(Player player : Bukkit.getOnlinePlayers()) { 
                       if(player.getInventory().contains(Material.SHEARS)){
                          ItemStack item = new ItemStack(Material.SHEARS);
                          ItemMeta meta = item.getItemMeta();
                          meta.setDisplayName(ChatColor.YELLOW + "Wire Cutters");
                          item.setItemMeta(meta);
                       }
                   }
                   }
               }, 0L, 10L);
        }         
    }
    
    Maybe im doing something wrong or maybe it isnt even possible.
     
    Last edited by a moderator: Jun 13, 2017
  2. Online

    timtower Administrator Administrator Moderator

    @Deathkilla Concept is good.
    You are creating a new itemstack though, you are not using the original ones.
     
    MelonCola and SirGregg like this.
  3. Offline

    Deathkilla

    I figured it out thanks
     
  4. Offline

    Zombie_Striker

    @Deathkilla
    If your problem has been solved, mark this thread as solved.
     
    MelonCola likes this.
Thread Status:
Not open for further replies.

Share This Page