Skip to content

Commit

Permalink
fixed nullpointerexception
Browse files Browse the repository at this point in the history
  • Loading branch information
poyrazinan committed Aug 17, 2024
1 parent c19b77a commit 8f39e62
Showing 1 changed file with 19 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,23 +65,26 @@ public void onVoucherUseEvent(@NotNull PlayerInteractEvent event) {
ChatUtils.sendMessage(player, Main.getLangFile().getMessages().getNotOwner());
return;
}
if (FarmerManager.getFarmers().containsKey(Main.getIntegration().getRegionID(player.getLocation()))) {
if (Main.getModulesFile().getVoucher().isUseWhenFarmerExist()) {
Farmer farmer = FarmerManager.getFarmers().get(Main.getIntegration().getRegionID(player.getLocation()));
if ((voucherLevel-1) > FarmerLevel.getAllLevels().indexOf(farmer.getLevel())) {
farmer.setLevel(FarmerLevel.getAllLevels().get(voucherLevel-1));
player.sendMessage(Voucher.getInstance().getLang().getText("changedLevel")
.replace("%level%", voucherLevel+""));
XSound.ENTITY_PLAYER_LEVELUP.play(player);
descentVoucher(player, event.getItem());
return;
}
else
player.sendMessage(Voucher.getInstance().getLang().getText("levelHigher"));
try {
if (FarmerManager.getFarmers().containsKey(Main.getIntegration().getRegionID(player.getLocation()))) {
if (Main.getModulesFile().getVoucher().isUseWhenFarmerExist()) {
Farmer farmer = FarmerManager.getFarmers().get(Main.getIntegration().getRegionID(player.getLocation()));
if ((voucherLevel - 1) > FarmerLevel.getAllLevels().indexOf(farmer.getLevel())) {
farmer.setLevel(FarmerLevel.getAllLevels().get(voucherLevel - 1));
player.sendMessage(Voucher.getInstance().getLang().getText("changedLevel")
.replace("%level%", voucherLevel + ""));
XSound.ENTITY_PLAYER_LEVELUP.play(player);
descentVoucher(player, event.getItem());
return;
} else
player.sendMessage(Voucher.getInstance().getLang().getText("levelHigher"));
} else
player.sendMessage(Voucher.getInstance().getLang().getText("alreadyHaveFarmer"));
return;
}
else
player.sendMessage(Voucher.getInstance().getLang().getText("alreadyHaveFarmer"));
return;
}
catch (Exception e1) {
return;
}
// Creates new farmer
Farmer farmer = new Farmer(Main.getIntegration()
Expand Down

0 comments on commit 8f39e62

Please sign in to comment.