forked from Upstream/mmocore
Added the possibility to give vanilla exp with fishing drop items.
This commit is contained in:
parent
8000bc9b89
commit
9b7d0c35b7
@ -11,55 +11,63 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class FishingDropItem implements Weighted {
|
||||
private final RandomAmount experience, tugs;
|
||||
private final DropItem dropItem;
|
||||
private final RandomAmount experience, tugs, vanillaExp;
|
||||
private final DropItem dropItem;
|
||||
|
||||
public FishingDropItem(MMOLineConfig config) {
|
||||
config.validateKeys("tugs", "experience");
|
||||
public FishingDropItem(MMOLineConfig config) {
|
||||
config.validateKeys("tugs", "experience");
|
||||
|
||||
tugs = new RandomAmount(config.getString("tugs"));
|
||||
experience = new RandomAmount(config.getString("experience"));
|
||||
tugs = new RandomAmount(config.getString("tugs"));
|
||||
experience = new RandomAmount(config.getString("experience"));
|
||||
vanillaExp = config.contains("vanilla-exp") ? new RandomAmount(config.getString("vanilla-experience")) : new RandomAmount(0, 0);
|
||||
dropItem = MMOCore.plugin.loadManager.loadDropItem(config);
|
||||
}
|
||||
|
||||
dropItem = MMOCore.plugin.loadManager.loadDropItem(config);
|
||||
}
|
||||
/**
|
||||
* An item cannot have a negative weight. Since drop items have 0 weight
|
||||
* by default, MMOCore takes 1 as minimum value if the item weight is
|
||||
* negative or equal to 0
|
||||
*/
|
||||
@Override
|
||||
public double getWeight() {
|
||||
return dropItem.getWeight() <= 0 ? 1 : dropItem.getWeight();
|
||||
}
|
||||
|
||||
/**
|
||||
* An item cannot have a negative weight. Since drop items have 0 weight
|
||||
* by default, MMOCore takes 1 as minimum value if the item weight is
|
||||
* negative or equal to 0
|
||||
*/
|
||||
@Override
|
||||
public double getWeight() {
|
||||
return dropItem.getWeight() <= 0 ? 1 : dropItem.getWeight();
|
||||
}
|
||||
public DropItem getItem() {
|
||||
return dropItem;
|
||||
}
|
||||
|
||||
public DropItem getItem() {
|
||||
return dropItem;
|
||||
}
|
||||
public RandomAmount getExperience() {
|
||||
return experience;
|
||||
}
|
||||
|
||||
public RandomAmount getExperience() {
|
||||
return experience;
|
||||
}
|
||||
public RandomAmount getVanillaExp() {
|
||||
return vanillaExp;
|
||||
}
|
||||
|
||||
public RandomAmount getTugs() {
|
||||
return tugs;
|
||||
}
|
||||
public RandomAmount getTugs() {
|
||||
return tugs;
|
||||
}
|
||||
|
||||
public int rollExperience() {
|
||||
return experience.calculateInt();
|
||||
}
|
||||
public int rollExperience() {
|
||||
return experience.calculateInt();
|
||||
}
|
||||
|
||||
public int rollTugs() {
|
||||
return tugs.calculateInt();
|
||||
}
|
||||
public int rollVanillaExp() {
|
||||
return vanillaExp.calculateInt();
|
||||
}
|
||||
|
||||
public DropItem getDropItem() {
|
||||
return dropItem;
|
||||
}
|
||||
public int rollTugs() {
|
||||
return tugs.calculateInt();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ItemStack collect(LootBuilder builder) {
|
||||
dropItem.collect(builder);
|
||||
return builder.getLoot().stream().findAny().orElse(null);
|
||||
}
|
||||
public DropItem getDropItem() {
|
||||
return dropItem;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ItemStack collect(LootBuilder builder) {
|
||||
dropItem.collect(builder);
|
||||
return builder.getLoot().stream().findAny().orElse(null);
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ public class FishingListener implements Listener {
|
||||
private final Player player;
|
||||
private final FishHook hook;
|
||||
|
||||
private final int fishStrength, experienceDropped;
|
||||
private final int fishStrength, experienceDropped, vanillaExpDropped;
|
||||
|
||||
private int currentPulls;
|
||||
|
||||
@ -82,7 +82,7 @@ public class FishingListener implements Listener {
|
||||
|
||||
this.fishStrength = (int) Math.floor(caught.rollTugs() * (1 - PlayerData.get(player).getStats().getStat("FISHING_STRENGTH") / 100));
|
||||
this.experienceDropped = caught.rollExperience();
|
||||
|
||||
this.vanillaExpDropped = caught.rollVanillaExp();
|
||||
fishing.add(player.getUniqueId());
|
||||
runTaskTimer(MMOCore.plugin, 0, 2);
|
||||
Bukkit.getPluginManager().registerEvents(this, MMOCore.plugin);
|
||||
@ -195,7 +195,7 @@ public class FishingListener implements Listener {
|
||||
player.getWorld().playSound(player.getLocation(), VersionSound.BLOCK_NOTE_BLOCK_HAT.toSound(), 1, 0);
|
||||
for (int j = 0; j < 8; j++)
|
||||
location.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, location, 0, 4 * (RANDOM.nextDouble() - .5), RANDOM.nextDouble() + 1, 4 * (RANDOM.nextDouble() - .5), .08);
|
||||
|
||||
player.giveExp(vanillaExpDropped);
|
||||
if (MMOCore.plugin.fishingManager.hasLinkedProfession())
|
||||
playerData.getCollectionSkills().giveExperience(MMOCore.plugin.fishingManager.getLinkedProfession(), experienceDropped, EXPSource.FISHING, location, true);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user