Mirror von
https://github.com/Moulberry/AxiomPaperPlugin.git
synchronisiert 2024-09-29 16:00:04 +02:00
refactor: add more properties to AxiomManipulateEntityEvent
Dieser Commit ist enthalten in:
Ursprung
47dcc38e94
Commit
ba2d7f9913
@ -19,13 +19,22 @@ public class AxiomManipulateEntityEvent extends Event implements Cancellable {
|
|||||||
|
|
||||||
private final Player player;
|
private final Player player;
|
||||||
private final UUID entityUUID;
|
private final UUID entityUUID;
|
||||||
|
private final Location fromLocation;
|
||||||
private final Location toLocation;
|
private final Location toLocation;
|
||||||
|
|
||||||
private boolean cancelled = false;
|
private boolean cancelled = false;
|
||||||
|
|
||||||
public AxiomManipulateEntityEvent(Player player, UUID entityUUID, Location toLocation) {
|
public AxiomManipulateEntityEvent(Player player, Entity entity, Location toLocation) {
|
||||||
|
this.player = player;
|
||||||
|
this.entityUUID = entity.getUniqueId();
|
||||||
|
this.fromLocation = entity.getLocation();
|
||||||
|
this.toLocation = toLocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AxiomManipulateEntityEvent(Player player, UUID entityUUID, Location fromLocation, Location toLocation) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.entityUUID = entityUUID;
|
this.entityUUID = entityUUID;
|
||||||
|
this.fromLocation = fromLocation;
|
||||||
this.toLocation = toLocation;
|
this.toLocation = toLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,6 +42,10 @@ public class AxiomManipulateEntityEvent extends Event implements Cancellable {
|
|||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Location getFromLocation() {
|
||||||
|
return fromLocation;
|
||||||
|
}
|
||||||
|
|
||||||
public Location getToLocation() {
|
public Location getToLocation() {
|
||||||
return toLocation;
|
return toLocation;
|
||||||
}
|
}
|
||||||
|
@ -120,11 +120,16 @@ public class ManipulateEntityPacketListener implements PluginMessageListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (entry.merge != null && !entry.merge.isEmpty()) {
|
if (entry.merge != null && !entry.merge.isEmpty()) {
|
||||||
|
final Location oldLocation = entity.getBukkitEntity().getLocation();
|
||||||
NbtSanitization.sanitizeEntity(entry.merge);
|
NbtSanitization.sanitizeEntity(entry.merge);
|
||||||
|
|
||||||
CompoundTag compoundTag = entity.saveWithoutId(new CompoundTag());
|
CompoundTag compoundTag = entity.saveWithoutId(new CompoundTag());
|
||||||
compoundTag = merge(compoundTag, entry.merge);
|
compoundTag = merge(compoundTag, entry.merge);
|
||||||
entity.load(compoundTag);
|
entity.load(compoundTag);
|
||||||
|
|
||||||
|
Location newLocation = new Location(serverLevel.getWorld(), position.x, position.y, position.z, entity.getBukkitYaw(), entity.getXRot());
|
||||||
|
AxiomManipulateEntityEvent manipulateEvent = new AxiomManipulateEntityEvent(player, entry.uuid, oldLocation, newLocation);
|
||||||
|
if (!manipulateEvent.callEvent()) continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
entity.setPosRaw(position.x, position.y, position.z);
|
entity.setPosRaw(position.x, position.y, position.z);
|
||||||
@ -138,7 +143,7 @@ public class ManipulateEntityPacketListener implements PluginMessageListener {
|
|||||||
float newPitch = entry.relativeMovementSet.contains(RelativeMovement.X_ROT) ? entity.getXRot() + entry.pitch : entry.pitch;
|
float newPitch = entry.relativeMovementSet.contains(RelativeMovement.X_ROT) ? entity.getXRot() + entry.pitch : entry.pitch;
|
||||||
Location newLocation = new Location(serverLevel.getWorld(), newX, newY, newZ, newYaw, newPitch);
|
Location newLocation = new Location(serverLevel.getWorld(), newX, newY, newZ, newYaw, newPitch);
|
||||||
|
|
||||||
AxiomManipulateEntityEvent manipulateEvent = new AxiomManipulateEntityEvent(player, entity.getUUID(), newLocation);
|
AxiomManipulateEntityEvent manipulateEvent = new AxiomManipulateEntityEvent(player, entity.getBukkitEntity(), newLocation);
|
||||||
if (!manipulateEvent.callEvent()) continue;
|
if (!manipulateEvent.callEvent()) continue;
|
||||||
|
|
||||||
if (entity instanceof HangingEntity hangingEntity) {
|
if (entity instanceof HangingEntity hangingEntity) {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren