mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-12-27 19:17:44 +01:00
Fixes issue #315 - Fishing will now properly respect min/max levels in
treasures.yml
This commit is contained in:
parent
0c61cc8bdc
commit
2ed5e8e717
@ -25,11 +25,7 @@ public class TreasuresConfig extends ConfigLoader{
|
||||
public List<ExcavationTreasure> excavationFromClay = new ArrayList<ExcavationTreasure>();
|
||||
public List<ExcavationTreasure> excavationFromMycel = new ArrayList<ExcavationTreasure>();
|
||||
public List<ExcavationTreasure> excavationFromSoulSand = new ArrayList<ExcavationTreasure>();
|
||||
public List<FishingTreasure> fishingRewardsTier1 = new ArrayList<FishingTreasure>();
|
||||
public List<FishingTreasure> fishingRewardsTier2 = new ArrayList<FishingTreasure>();
|
||||
public List<FishingTreasure> fishingRewardsTier3 = new ArrayList<FishingTreasure>();
|
||||
public List<FishingTreasure> fishingRewardsTier4 = new ArrayList<FishingTreasure>();
|
||||
public List<FishingTreasure> fishingRewardsTier5 = new ArrayList<FishingTreasure>();
|
||||
public List<FishingTreasure> fishingRewards = new ArrayList<FishingTreasure>();
|
||||
|
||||
private TreasuresConfig() {
|
||||
super("treasures.yml");
|
||||
@ -198,30 +194,7 @@ public class TreasuresConfig extends ConfigLoader{
|
||||
continue;
|
||||
}
|
||||
|
||||
FishingTreasure fTreasure = (FishingTreasure) treasure;
|
||||
int dropLevel = fTreasure.getDropLevel();
|
||||
int maxLevel = fTreasure.getMaxLevel();
|
||||
|
||||
if (dropLevel <= AdvancedConfig.getInstance().getFishingTierLevelsTier1() && maxLevel >= AdvancedConfig.getInstance().getFishingTierLevelsTier1()) {
|
||||
fishingRewardsTier1.add(fTreasure);
|
||||
}
|
||||
|
||||
if (dropLevel <= AdvancedConfig.getInstance().getFishingTierLevelsTier2() && maxLevel >= AdvancedConfig.getInstance().getFishingTierLevelsTier2()) {
|
||||
fishingRewardsTier2.add(fTreasure);
|
||||
}
|
||||
|
||||
if (dropLevel <= AdvancedConfig.getInstance().getFishingTierLevelsTier3() && maxLevel >= AdvancedConfig.getInstance().getFishingTierLevelsTier3()) {
|
||||
fishingRewardsTier3.add(fTreasure);
|
||||
}
|
||||
|
||||
if (dropLevel <= AdvancedConfig.getInstance().getFishingTierLevelsTier4() && maxLevel >= AdvancedConfig.getInstance().getFishingTierLevelsTier4()) {
|
||||
fishingRewardsTier4.add(fTreasure);
|
||||
}
|
||||
|
||||
if (dropLevel <= AdvancedConfig.getInstance().getFishingTierLevelsTier5() && maxLevel >= AdvancedConfig.getInstance().getFishingTierLevelsTier5()) {
|
||||
fishingRewardsTier5.add(fTreasure);
|
||||
}
|
||||
|
||||
fishingRewards.add((FishingTreasure) treasure);
|
||||
}
|
||||
else if (treasure instanceof ExcavationTreasure) {
|
||||
if (!excavationTreasures.contains(treasureKey)) {
|
||||
|
@ -77,50 +77,35 @@ public class Fishing {
|
||||
return;
|
||||
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
List<FishingTreasure> rewards = new ArrayList<FishingTreasure>();
|
||||
Item theCatch = (Item) event.getCaught();
|
||||
|
||||
switch (getFishingLootTier(profile)) {
|
||||
case 1:
|
||||
rewards = TreasuresConfig.getInstance().fishingRewardsTier1;
|
||||
break;
|
||||
if (Config.getInstance().getFishingDropsEnabled() && Permissions.fishingTreasures(player)) {
|
||||
int skillLevel = profile.getSkillLevel(SkillType.FISHING);
|
||||
List<FishingTreasure> rewards = new ArrayList<FishingTreasure>();
|
||||
|
||||
case 2:
|
||||
rewards = TreasuresConfig.getInstance().fishingRewardsTier2;
|
||||
break;
|
||||
for (FishingTreasure treasure : TreasuresConfig.getInstance().fishingRewards) {
|
||||
if (treasure.getDropLevel() <= skillLevel && treasure.getMaxLevel() >= skillLevel) {
|
||||
rewards.add(treasure);
|
||||
}
|
||||
}
|
||||
|
||||
case 3:
|
||||
rewards = TreasuresConfig.getInstance().fishingRewardsTier3;
|
||||
break;
|
||||
if (rewards.size() <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
case 4:
|
||||
rewards = TreasuresConfig.getInstance().fishingRewardsTier4;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
rewards = TreasuresConfig.getInstance().fishingRewardsTier5;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getFishingDropsEnabled() && rewards.size() > 0
|
||||
&& Permissions.fishingTreasures(player)) {
|
||||
FishingTreasure treasure;
|
||||
treasure = rewards.get(Misc.getRandom().nextInt(rewards.size()));
|
||||
FishingTreasure foundTreasure = rewards.get(Misc.getRandom().nextInt(rewards.size()));
|
||||
|
||||
int randomChance = 100;
|
||||
|
||||
if (Permissions.luckyFishing(player)) {
|
||||
randomChance = (int) (randomChance * 0.75);
|
||||
}
|
||||
|
||||
if (Misc.getRandom().nextDouble() * randomChance <= treasure.getDropChance()) {
|
||||
Users.getPlayer(player).addXP(SkillType.FISHING,treasure.getXp());
|
||||
theCatch.setItemStack(treasure.getDrop());
|
||||
if (Misc.getRandom().nextDouble() * randomChance <= foundTreasure.getDropChance()) {
|
||||
Users.getPlayer(player).addXP(SkillType.FISHING, foundTreasure.getXp());
|
||||
theCatch.setItemStack(foundTreasure.getDrop());
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
theCatch.setItemStack(new ItemStack(Material.RAW_FISH));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user