-
-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#217 * Added EXPERIENCE_PICKUP flag (as a PROTECTION flag) * Created ExperiencePickupListener * Updated en-US locale accordingly
- Loading branch information
1 parent
486de0d
commit f61b109
Showing
3 changed files
with
38 additions
and
34 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
src/main/java/world/bentobox/bentobox/listeners/flags/ExperiencePickupListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package world.bentobox.bentobox.listeners.flags; | ||
|
||
import org.bukkit.entity.ExperienceOrb; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.EventPriority; | ||
import org.bukkit.event.entity.EntityTargetLivingEntityEvent; | ||
import world.bentobox.bentobox.api.flags.FlagListener; | ||
import world.bentobox.bentobox.api.user.User; | ||
import world.bentobox.bentobox.lists.Flags; | ||
|
||
/** | ||
* Handles the {@link world.bentobox.bentobox.lists.Flags#EXPERIENCE_PICKUP} flag. | ||
* | ||
* @author Poslovitch | ||
*/ | ||
public class ExperiencePickupListener extends FlagListener { | ||
|
||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) | ||
public void onExperienceOrbTargetPlayer(EntityTargetLivingEntityEvent e) { | ||
// Make sure the target is a Player and the entity is an experience orb | ||
if (e.getTarget() instanceof Player && e.getEntity() instanceof ExperienceOrb) { | ||
setUser(User.getInstance((Player) e.getTarget())); | ||
if (!checkIsland(e, e.getEntity().getLocation(), Flags.EXPERIENCE_PICKUP)) { | ||
// Cancelling the event won't be enough, we need to explicitly set the target to null | ||
e.setTarget(null); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters