mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-12-28 11:37:39 +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> excavationFromClay = new ArrayList<ExcavationTreasure>();
|
||||||
public List<ExcavationTreasure> excavationFromMycel = new ArrayList<ExcavationTreasure>();
|
public List<ExcavationTreasure> excavationFromMycel = new ArrayList<ExcavationTreasure>();
|
||||||
public List<ExcavationTreasure> excavationFromSoulSand = new ArrayList<ExcavationTreasure>();
|
public List<ExcavationTreasure> excavationFromSoulSand = new ArrayList<ExcavationTreasure>();
|
||||||
public List<FishingTreasure> fishingRewardsTier1 = new ArrayList<FishingTreasure>();
|
public List<FishingTreasure> fishingRewards = 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>();
|
|
||||||
|
|
||||||
private TreasuresConfig() {
|
private TreasuresConfig() {
|
||||||
super("treasures.yml");
|
super("treasures.yml");
|
||||||
@ -198,30 +194,7 @@ public class TreasuresConfig extends ConfigLoader{
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
FishingTreasure fTreasure = (FishingTreasure) treasure;
|
fishingRewards.add((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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (treasure instanceof ExcavationTreasure) {
|
else if (treasure instanceof ExcavationTreasure) {
|
||||||
if (!excavationTreasures.contains(treasureKey)) {
|
if (!excavationTreasures.contains(treasureKey)) {
|
||||||
|
@ -77,50 +77,35 @@ public class Fishing {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
PlayerProfile profile = Users.getProfile(player);
|
PlayerProfile profile = Users.getProfile(player);
|
||||||
List<FishingTreasure> rewards = new ArrayList<FishingTreasure>();
|
|
||||||
Item theCatch = (Item) event.getCaught();
|
Item theCatch = (Item) event.getCaught();
|
||||||
|
|
||||||
switch (getFishingLootTier(profile)) {
|
if (Config.getInstance().getFishingDropsEnabled() && Permissions.fishingTreasures(player)) {
|
||||||
case 1:
|
int skillLevel = profile.getSkillLevel(SkillType.FISHING);
|
||||||
rewards = TreasuresConfig.getInstance().fishingRewardsTier1;
|
List<FishingTreasure> rewards = new ArrayList<FishingTreasure>();
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
for (FishingTreasure treasure : TreasuresConfig.getInstance().fishingRewards) {
|
||||||
rewards = TreasuresConfig.getInstance().fishingRewardsTier2;
|
if (treasure.getDropLevel() <= skillLevel && treasure.getMaxLevel() >= skillLevel) {
|
||||||
break;
|
rewards.add(treasure);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case 3:
|
if (rewards.size() <= 0) {
|
||||||
rewards = TreasuresConfig.getInstance().fishingRewardsTier3;
|
return;
|
||||||
break;
|
}
|
||||||
|
|
||||||
case 4:
|
FishingTreasure foundTreasure = rewards.get(Misc.getRandom().nextInt(rewards.size()));
|
||||||
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()));
|
|
||||||
|
|
||||||
int randomChance = 100;
|
int randomChance = 100;
|
||||||
|
|
||||||
if (Permissions.luckyFishing(player)) {
|
if (Permissions.luckyFishing(player)) {
|
||||||
randomChance = (int) (randomChance * 0.75);
|
randomChance = (int) (randomChance * 0.75);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Misc.getRandom().nextDouble() * randomChance <= treasure.getDropChance()) {
|
if (Misc.getRandom().nextDouble() * randomChance <= foundTreasure.getDropChance()) {
|
||||||
Users.getPlayer(player).addXP(SkillType.FISHING,treasure.getXp());
|
Users.getPlayer(player).addXP(SkillType.FISHING, foundTreasure.getXp());
|
||||||
theCatch.setItemStack(treasure.getDrop());
|
theCatch.setItemStack(foundTreasure.getDrop());
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
theCatch.setItemStack(new ItemStack(Material.RAW_FISH));
|
theCatch.setItemStack(new ItemStack(Material.RAW_FISH));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user