Added DeleteVillagerInventoryOnCatch option.

This commit is contained in:
shansen 2016-03-12 02:34:04 +01:00
parent bf1ce3d38a
commit faa261de24
3 changed files with 12 additions and 3 deletions

View File

@ -64,9 +64,14 @@ public class EggCatcher extends JavaPlugin {
public void CheckConfigurationFile() { public void CheckConfigurationFile() {
double configVersion = this.getConfig().getDouble("ConfigVersion", 0.0); double configVersion = this.getConfig().getDouble("ConfigVersion", 0.0);
if (configVersion == 2.2) { if (configVersion == 2.5) {
// //
this.saveConfig(); this.saveConfig();
} else if (configVersion == 2.2) {
this.getConfig().set("DeleteVillagerInventoryOnCatch", false);
this.getConfig().set("ConfigVersion", 2.5);
this.saveConfig();
} else if (configVersion == 2.0) { } else if (configVersion == 2.0) {
this.getConfig().set("CatchChance.Endermite", 100.0); this.getConfig().set("CatchChance.Endermite", 100.0);
this.getConfig().set("VaultCost.Endermite", 0); this.getConfig().set("VaultCost.Endermite", 0);

View File

@ -57,6 +57,7 @@ public class EggCatcherEntityListener implements Listener {
private final String vaultTargetBankAccount; private final String vaultTargetBankAccount;
private final boolean spawnChickenOnFail; private final boolean spawnChickenOnFail;
private final boolean spawnChickenOnSuccess; private final boolean spawnChickenOnSuccess;
private final boolean deleteVillagerInventoryOnCatch;
FileConfiguration config; FileConfiguration config;
JavaPlugin plugin; JavaPlugin plugin;
@ -81,6 +82,7 @@ public class EggCatcherEntityListener implements Listener {
this.spawnChickenOnFail = this.config.getBoolean("SpawnChickenOnFail", true); this.spawnChickenOnFail = this.config.getBoolean("SpawnChickenOnFail", true);
this.spawnChickenOnSuccess = this.config.getBoolean("SpawnChickenOnSuccess", false); this.spawnChickenOnSuccess = this.config.getBoolean("SpawnChickenOnSuccess", false);
this.vaultTargetBankAccount = this.config.getString("VaultTargetBankAccount", ""); this.vaultTargetBankAccount = this.config.getString("VaultTargetBankAccount", "");
this.deleteVillagerInventoryOnCatch = this.config.getBoolean("DeleteVillagerInventoryOnCatch", false);
} }
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
@ -279,7 +281,8 @@ public class EggCatcherEntityListener implements Listener {
} }
} }
if(entity instanceof InventoryHolder){ if((entity instanceof Villager && !this.deleteVillagerInventoryOnCatch) ||
(!(entity instanceof Villager) && entity instanceof InventoryHolder)) {
ItemStack[] items = ((InventoryHolder) entity).getInventory().getContents(); ItemStack[] items = ((InventoryHolder) entity).getInventory().getContents();

View File

@ -13,6 +13,7 @@ PreventCatchingShearedSheeps: true
SpawnChickenOnSuccess: false SpawnChickenOnSuccess: false
SpawnChickenOnFail: true SpawnChickenOnFail: true
VaultTargetBankAccount: "" VaultTargetBankAccount: ""
DeleteVillagerInventoryOnCatch: false
CatchChance: CatchChance:
Pig: 100.0 Pig: 100.0
Sheep: 100.0 Sheep: 100.0
@ -137,4 +138,4 @@ Messages:
CatchChanceFail: "You failed to catch this mob!" CatchChanceFail: "You failed to catch this mob!"
CatchChanceSuccess: "" CatchChanceSuccess: ""
HealthPercentageFail: "The mob has more than %s percent health left and cannot be caught!" HealthPercentageFail: "The mob has more than %s percent health left and cannot be caught!"
ConfigVersion: 2.2 ConfigVersion: 2.5