Added the possibility to give vanilla exp with fishing drop items.

This commit is contained in:
Ka0rX 2023-06-24 22:46:45 +01:00
parent 8000bc9b89
commit 9b7d0c35b7
2 changed files with 51 additions and 43 deletions

View File

@ -11,7 +11,7 @@ import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
public class FishingDropItem implements Weighted { public class FishingDropItem implements Weighted {
private final RandomAmount experience, tugs; private final RandomAmount experience, tugs, vanillaExp;
private final DropItem dropItem; private final DropItem dropItem;
public FishingDropItem(MMOLineConfig config) { public FishingDropItem(MMOLineConfig config) {
@ -19,7 +19,7 @@ public class FishingDropItem implements Weighted {
tugs = new RandomAmount(config.getString("tugs")); tugs = new RandomAmount(config.getString("tugs"));
experience = new RandomAmount(config.getString("experience")); 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);
} }
@ -41,6 +41,10 @@ public class FishingDropItem implements Weighted {
return experience; return experience;
} }
public RandomAmount getVanillaExp() {
return vanillaExp;
}
public RandomAmount getTugs() { public RandomAmount getTugs() {
return tugs; return tugs;
} }
@ -49,6 +53,10 @@ public class FishingDropItem implements Weighted {
return experience.calculateInt(); return experience.calculateInt();
} }
public int rollVanillaExp() {
return vanillaExp.calculateInt();
}
public int rollTugs() { public int rollTugs() {
return tugs.calculateInt(); return tugs.calculateInt();
} }

View File

@ -61,7 +61,7 @@ public class FishingListener implements Listener {
private final Player player; private final Player player;
private final FishHook hook; private final FishHook hook;
private final int fishStrength, experienceDropped; private final int fishStrength, experienceDropped, vanillaExpDropped;
private int currentPulls; 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.fishStrength = (int) Math.floor(caught.rollTugs() * (1 - PlayerData.get(player).getStats().getStat("FISHING_STRENGTH") / 100));
this.experienceDropped = caught.rollExperience(); this.experienceDropped = caught.rollExperience();
this.vanillaExpDropped = caught.rollVanillaExp();
fishing.add(player.getUniqueId()); fishing.add(player.getUniqueId());
runTaskTimer(MMOCore.plugin, 0, 2); runTaskTimer(MMOCore.plugin, 0, 2);
Bukkit.getPluginManager().registerEvents(this, MMOCore.plugin); 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); player.getWorld().playSound(player.getLocation(), VersionSound.BLOCK_NOTE_BLOCK_HAT.toSound(), 1, 0);
for (int j = 0; j < 8; j++) 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); 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()) if (MMOCore.plugin.fishingManager.hasLinkedProfession())
playerData.getCollectionSkills().giveExperience(MMOCore.plugin.fishingManager.getLinkedProfession(), experienceDropped, EXPSource.FISHING, location, true); playerData.getCollectionSkills().giveExperience(MMOCore.plugin.fishingManager.getLinkedProfession(), experienceDropped, EXPSource.FISHING, location, true);
} }