Skip to content

Instantly share code, notes, and snippets.

@CeramicTitan
Last active December 22, 2015 10:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CeramicTitan/6462779 to your computer and use it in GitHub Desktop.
Save CeramicTitan/6462779 to your computer and use it in GitHub Desktop.
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){
@Override
public void run() {
for(Player p : Bukkit.getOnlinePlayers()){//Gets all the online platers
if(p.getInventory().getArmorContents() != null){
for(ItemStack armour : p.getInventory().getArmorContents()){
armour.setDurability((short)0);//Keeping durability at a constant durability
}
}
if(p.getInventory().contains(Material.WOOD_SWORD)
|| p.getInventory().contains(Material.IRON_SWORD)
|| p.getInventory().contains(Material.GOLD_SWORD)
|| p.getInventory().contains(Material.DIAMOND_SWORD)){//Checking if the inventory contains swords
for(int x=1; x<=33;x++){
if(p.getInventory().getItem(x) != null && p.getInventory().getItem(x).getType() == Material.WOOD_SWORD
|| p.getInventory().getItem(x).getType() == Material.IRON_SWORD
|| p.getInventory().getItem(x).getType() == Material.GOLD_SWORD
|| p.getInventory().getItem(x).getType() == Material.DIAMOND_SWORD){//Getting all the swords
p.getInventory().getItem(x).setDurability((short) 0);//Keeping durability at a constant durability
}
}
}
}
}
}, 0L, 20L);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment