Refactor code for clarity: standardize optional checks, improve list handling, and adjust PhantomPreSpawnEvent import.
This commit is contained in:
@@ -25,8 +25,9 @@ public class MyPetListener implements Listener {
|
||||
}
|
||||
|
||||
Optional<Booster> myPetBooster = boosterCache.getActiveBooster(BoosterType.MYPET);
|
||||
if (myPetBooster.isEmpty())
|
||||
if (myPetBooster.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Booster booster = myPetBooster.get();
|
||||
event.setExp(booster.useMultiplier(event.getExp()));
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.alttd.boosters.listeners;
|
||||
|
||||
import com.alttd.boosterapi.data.BoosterCache;
|
||||
import com.alttd.boosterapi.data.BoosterType;
|
||||
import com.destroystokyo.paper.event.entity.PhantomPreSpawnEvent;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -16,7 +17,7 @@ public class PhantomSpawnListener implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPhantomPreSpawn(com.destroystokyo.paper.event.entity.PhantomPreSpawnEvent event) {
|
||||
public void onPhantomPreSpawn(PhantomPreSpawnEvent event) {
|
||||
Entity spawningEntity = event.getSpawningEntity();
|
||||
if (spawningEntity instanceof Player
|
||||
&& boosterCache.getActiveBooster(BoosterType.PHANTOM).isPresent()) {
|
||||
|
||||
@@ -23,8 +23,9 @@ public class mcMMOListener implements Listener {
|
||||
String skillName = event.getSkill().name();
|
||||
BoosterType type = BoosterType.getByName(skillName);
|
||||
Optional<Booster> optionalBooster = boosterCache.getActiveBooster(type);
|
||||
if (optionalBooster.isEmpty())
|
||||
if (optionalBooster.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Booster booster = optionalBooster.get();
|
||||
event.setRawXpGained(Math.round(booster.useMultiplier(event.getRawXpGained())));
|
||||
|
||||
Reference in New Issue
Block a user