9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-30 04:19:27 +00:00

Refactor entity interaction and imports

Replaced redundant event.getPlayer() call with local variable in ItemEventListener and updated import statements in EntityUtils for clarity and specificity.
This commit is contained in:
halogly
2025-07-18 14:42:44 +08:00
parent 76e98cda00
commit 774a9a9207
2 changed files with 5 additions and 2 deletions

View File

@@ -69,7 +69,7 @@ public class ItemEventListener implements Listener {
public void onInteractEntity(PlayerInteractEntityEvent event) {
Player player = event.getPlayer();
Entity entity = event.getRightClicked();
BukkitServerPlayer serverPlayer = this.plugin.adapt(event.getPlayer());
BukkitServerPlayer serverPlayer = this.plugin.adapt(player);
if (serverPlayer == null) return;
InteractionHand hand = event.getHand() == EquipmentSlot.HAND ? InteractionHand.MAIN_HAND : InteractionHand.OFF_HAND;
Item<ItemStack> itemInHand = serverPlayer.getItemInHand(hand);

View File

@@ -8,7 +8,10 @@ import net.momirealms.craftengine.core.util.VersionHelper;
import net.momirealms.craftengine.core.world.BlockPos;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.*;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.inventory.EntityEquipment;
import org.bukkit.inventory.EquipmentSlot;