mirror of
				https://github.com/mcMMO-Dev/mcMMO.git
				synced 2025-10-31 01:03:44 +01:00 
			
		
		
		
	Beginnings of the repairable
This commit is contained in:
		| @@ -0,0 +1,49 @@ | ||||
| package com.gmail.nossr50.skills.repair; | ||||
|  | ||||
| public interface Repairable { | ||||
|     /** | ||||
|      * Gets the item id of this repairable item | ||||
|      * | ||||
|      * @return the id of this repairable | ||||
|      */ | ||||
|     public int getItemId(); | ||||
|  | ||||
|     /** | ||||
|      * Gets the id of the material used to repair this item | ||||
|      * | ||||
|      * @return the id of the repair material | ||||
|      */ | ||||
|     public int getRepairMaterialId(); | ||||
|  | ||||
|     /** | ||||
|      * Gets the minimum quantity of repair materials ignoring all other repair bonuses | ||||
|      * | ||||
|      * This is typically set to the number of items needed to create that item, for example 5 for helmets or 2 for swords | ||||
|      * | ||||
|      * @return the minimum number of items | ||||
|      */ | ||||
|     public int getMinimumQuantity(); | ||||
|  | ||||
|     /** | ||||
|      * Gets the maximum durability of this item before it breaks | ||||
|      * | ||||
|      * @return the maximum durability | ||||
|      */ | ||||
|     public short getMaximumDurability(); | ||||
|  | ||||
|     /** | ||||
|      * Gets the base repair durability on which to calcuate bonuses. | ||||
|      * | ||||
|      * This is actually the maximum durability divided by the minimum quantity | ||||
|      * | ||||
|      * @return the base repair durability | ||||
|      */ | ||||
|     public short getBaseRepairDurability(); | ||||
|  | ||||
|     /** | ||||
|      * Gets the minimum repair level needed to repair this item | ||||
|      * | ||||
|      * @return the minimum level to repair this item, or 0 for no minimum | ||||
|      */ | ||||
|     public int getMinimumLevel(); | ||||
| } | ||||
| @@ -0,0 +1,8 @@ | ||||
| package com.gmail.nossr50.skills.repair; | ||||
|  | ||||
| public class RepairableFactory { | ||||
|     public static Repairable getRepairable(int itemId, int repairMaterialId, int minimumLevel, int minimumQuantity, short maximumDurability) { | ||||
|         // TODO: Add in loading from config what type of manager we want. | ||||
|         return new SimpleRepairable(itemId, repairMaterialId, minimumLevel, minimumQuantity, maximumDurability); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,45 @@ | ||||
| package com.gmail.nossr50.skills.repair; | ||||
|  | ||||
| public class SimpleRepairable implements Repairable { | ||||
|     private final int itemId, repairMaterialId, minimumQuantity, minimumLevel; | ||||
|     private final short maximumDurability, baseRepairDurability; | ||||
|  | ||||
|     protected SimpleRepairable(int itemId, int repairMaterialId, int minimumLevel, int minimumQuantity, short maximumDurability) { | ||||
|         this.itemId = itemId; | ||||
|         this.repairMaterialId = repairMaterialId; | ||||
|         this.minimumLevel = minimumLevel; | ||||
|         this.minimumQuantity = minimumQuantity; | ||||
|         this.maximumDurability = maximumDurability; | ||||
|         this.baseRepairDurability = (short) (maximumDurability / minimumQuantity); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public int getItemId() { | ||||
|         return itemId; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public int getRepairMaterialId() { | ||||
|         return repairMaterialId; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public int getMinimumQuantity() { | ||||
|         return minimumQuantity; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public short getMaximumDurability() { | ||||
|         return maximumDurability; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public short getBaseRepairDurability() { | ||||
|         return baseRepairDurability; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public int getMinimumLevel() { | ||||
|         return minimumLevel; | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 NuclearW
					NuclearW