Skip to content

Commit

Permalink
Recreate Boy0000/entity-manip-event
Browse files Browse the repository at this point in the history
  • Loading branch information
Moulberry committed Jun 26, 2024
1 parent 3ee22dd commit 758e0b4
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.moulberry.axiom.event;

import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;

public class AxiomManipulateEntityEvent extends Event implements Cancellable {

private static final HandlerList HANDLERS = new HandlerList();

private final Player player;
private final Entity entity;

private boolean cancelled = false;

public AxiomManipulateEntityEvent(Player player, @NotNull Entity entity) {
this.player = player;
this.entity = entity;
}

public Player getPlayer() {
return player;
}

public Entity getEntity() {
return entity;
}

@Override
public boolean isCancelled() {
return this.cancelled;
}

@Override
public void setCancelled(boolean cancel) {
this.cancelled = cancel;
}

public static HandlerList getHandlerList() {
return HANDLERS;
}

@Override
public @NotNull HandlerList getHandlers() {
return HANDLERS;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.moulberry.axiom.AxiomPaper;
import com.moulberry.axiom.NbtSanitization;
import com.moulberry.axiom.event.AxiomManipulateEntityEvent;
import com.moulberry.axiom.integration.Integration;
import com.moulberry.axiom.integration.plotsquared.PlotSquaredIntegration;
import com.moulberry.axiom.viaversion.UnknownVersionHelper;
Expand Down Expand Up @@ -124,6 +125,11 @@ private void process(Player player, byte[] message) {
continue;
}

AxiomManipulateEntityEvent manipulateEvent = new AxiomManipulateEntityEvent(player, entity.getBukkitEntity());
if (!manipulateEvent.callEvent()) {
continue;
}

if (entry.merge != null && !entry.merge.isEmpty()) {
NbtSanitization.sanitizeEntity(entry.merge);

Expand Down

0 comments on commit 758e0b4

Please sign in to comment.