Skip to content

Commit

Permalink
fix(listeners): fix NPE in onPlayerDamageEntity
Browse files Browse the repository at this point in the history
  • Loading branch information
ColdDev committed Nov 5, 2022
1 parent e50b5b8 commit 4f683e0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/main/java/uranium/listeners/PlayerListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public void onPlayerDropItem(PlayerDropItemEvent event) {
public void onPlayerInteract(PlayerInteractEvent event) {
if (!(event.getAction() == Action.RIGHT_CLICK_BLOCK)) return;
User user = UserManager.getUser(event.getPlayer());
if (user == null) return;
if (!user.isVanished()) return;

if (event.getClickedBlock().getType() == Material.CHEST
Expand All @@ -96,6 +97,7 @@ public void onPlayerInteract(PlayerInteractEvent event) {
@EventHandler(ignoreCancelled = true)
public void onInventoryClick(InventoryClickEvent event) {
User user = UserManager.getUser((Player) event.getWhoClicked());
if (user == null) return;
if (!user.isVanished()) return;

if (event.getInventory().getType() == InventoryType.CHEST)
Expand All @@ -106,6 +108,7 @@ public void onInventoryClick(InventoryClickEvent event) {
public void onPlayerDamageEntity(EntityDamageByEntityEvent event) {
if (!(event.getEntity() instanceof Player) || !(event.getDamager() instanceof Player)) return;
User user = UserManager.getUser((Player) event.getDamager());
if (user == null) return;

if (user.isVanished()) {
event.setCancelled(true);
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Uranium
version: 1.0-LITE
version: 1.0.1-LITE
main: uranium.Main
description: A moderation utility for Eaglercraft 1.8 servers.
author: Cold
Expand Down

0 comments on commit 4f683e0

Please sign in to comment.