Item: Moved getMaxDurability() to Durable class only, and make it abstract

It's only now used in the Durable class, so it does not make sense to keep it in Item anymore. This is a leftover from the days where Durable did not exist.
This commit is contained in:
Dylan K. Taylor 2018-01-18 14:16:30 +00:00
parent d728154e87
commit efca9f0450
6 changed files with 12 additions and 13 deletions

View File

@ -39,7 +39,7 @@ class Bow extends Tool{
return 200;
}
public function getMaxDurability(){
public function getMaxDurability() : int{
return 385;
}

View File

@ -82,6 +82,14 @@ abstract class Durable extends Item{
return 0;
}
/**
* Returns the maximum amount of damage this item can take before it breaks.
*
* @return int
*/
abstract public function getMaxDurability() : int;
/**
* Returns whether the item is broken.
* @return bool

View File

@ -49,7 +49,7 @@ class FlintSteel extends Tool{
return false;
}
public function getMaxDurability(){
public function getMaxDurability() : int{
return 65;
}
}

View File

@ -761,15 +761,6 @@ class Item implements ItemIds, \JsonSerializable{
return 0;
}
/**
* Returns the maximum amount of damage this item can take before it breaks.
*
* @return int|bool
*/
public function getMaxDurability(){
return false;
}
public function isPickaxe(){
return false;
}

View File

@ -30,7 +30,7 @@ class Shears extends Tool{
parent::__construct(self::SHEARS, $meta, "Shears");
}
public function getMaxDurability(){
public function getMaxDurability() : int{
return 239;
}

View File

@ -38,7 +38,7 @@ abstract class TieredTool extends Tool{
$this->tier = $tier;
}
public function getMaxDurability(){
public function getMaxDurability() : int{
return self::getDurabilityFromTier($this->tier);
}