mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-01-31 14:49:35 +01:00
Cleanup.
This commit is contained in:
parent
d7b8ec1274
commit
9525ce8299
@ -14,12 +14,10 @@ import com.gmail.nossr50.skills.repair.Repairable;
|
||||
import com.gmail.nossr50.skills.repair.RepairableFactory;
|
||||
|
||||
public class RepairConfig extends ConfigLoader {
|
||||
private final String fileName;
|
||||
private List<Repairable> repairables;
|
||||
|
||||
public RepairConfig(mcMMO plugin, String fileName) {
|
||||
super(plugin, fileName);
|
||||
this.fileName = fileName;
|
||||
this.config = YamlConfiguration.loadConfiguration(this.configFile);
|
||||
}
|
||||
|
||||
@ -75,13 +73,15 @@ public class RepairConfig extends ConfigLoader {
|
||||
|
||||
try {
|
||||
repairItemType = RepairItemType.valueOf(repairItemTypeString);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
reason.add(key + " has an invalid ItemType of " + repairItemTypeString);
|
||||
}
|
||||
|
||||
try {
|
||||
repairMaterialType = RepairMaterialType.valueOf(repairMaterialTypeString);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
reason.add(key + " has an invalid MaterialType of " + repairMaterialTypeString);
|
||||
}
|
||||
|
||||
@ -93,7 +93,10 @@ public class RepairConfig extends ConfigLoader {
|
||||
}
|
||||
|
||||
protected List<Repairable> getLoadedRepairables() {
|
||||
if(repairables == null) return new ArrayList<Repairable>();
|
||||
if (repairables == null) {
|
||||
return new ArrayList<Repairable>();
|
||||
}
|
||||
|
||||
return repairables;
|
||||
}
|
||||
|
||||
|
@ -19,10 +19,13 @@ public enum RepairItemType {
|
||||
switch (this) {
|
||||
case ARMOR:
|
||||
return Permissions.getInstance().armorRepair(player);
|
||||
|
||||
case TOOL:
|
||||
return Permissions.getInstance().toolRepair(player);
|
||||
|
||||
case OTHER:
|
||||
return Permissions.getInstance().otherRepair(player);
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
@ -24,20 +24,28 @@ public enum RepairMaterialType {
|
||||
switch (this) {
|
||||
case STRING:
|
||||
return Permissions.getInstance().stringRepair(player);
|
||||
|
||||
case LEATHER:
|
||||
return Permissions.getInstance().leatherRepair(player);
|
||||
|
||||
case WOOD:
|
||||
return Permissions.getInstance().woodRepair(player);
|
||||
|
||||
case STONE:
|
||||
return Permissions.getInstance().stoneRepair(player);
|
||||
|
||||
case IRON:
|
||||
return Permissions.getInstance().ironRepair(player);
|
||||
|
||||
case GOLD:
|
||||
return Permissions.getInstance().goldRepair(player);
|
||||
|
||||
case DIAMOND:
|
||||
return Permissions.getInstance().diamondRepair(player);
|
||||
|
||||
case OTHER:
|
||||
return Permissions.getInstance().otherMaterialRepair(player);
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
@ -110,14 +110,15 @@ public class SimpleRepairManager implements RepairManager {
|
||||
|
||||
// Lets get down to business,
|
||||
// To defeat, the huns.
|
||||
int baseRepairAmount = repairable.getBaseRepairDurability();
|
||||
short newDurability = Repair.repairCalculate(player, skillLevel, startDurability, baseRepairAmount);
|
||||
int baseRepairAmount = repairable.getBaseRepairDurability(); // Did they send me daughters?
|
||||
short newDurability = Repair.repairCalculate(player, skillLevel, startDurability, baseRepairAmount); // When I asked for sons?
|
||||
|
||||
// We're going to hold onto our repair item location
|
||||
int repairItemLocation;
|
||||
if (repairable.getRepairMaterialMetadata() == (byte) -1) {
|
||||
repairItemLocation = findInInventory(inventory, repairable.getRepairMaterialId());
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// Special case for when the repairable has metadata that must be addressed
|
||||
repairItemLocation = findInInventory(inventory, repairable.getRepairMaterialId(), repairable.getRepairMaterialMetadata());
|
||||
}
|
||||
@ -162,7 +163,8 @@ public class SimpleRepairManager implements RepairManager {
|
||||
ItemStack item = inventory.getItem(index);
|
||||
if (item.getAmount() > 1) {
|
||||
item.setAmount(item.getAmount() - 1);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
item = new ItemStack(0);
|
||||
}
|
||||
|
||||
@ -179,10 +181,12 @@ public class SimpleRepairManager implements RepairManager {
|
||||
*/
|
||||
private int findInInventory(PlayerInventory inventory, int itemId) {
|
||||
int location = inventory.first(itemId);
|
||||
|
||||
// VALIDATE
|
||||
if (inventory.getItem(location).getTypeId() == itemId) {
|
||||
return location;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -206,7 +210,9 @@ public class SimpleRepairManager implements RepairManager {
|
||||
location = i;
|
||||
}
|
||||
}
|
||||
if(location != -1) break;
|
||||
if (location != -1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return location;
|
||||
|
Loading…
x
Reference in New Issue
Block a user