Added location to CoreProtectPreLogEvent (implements #709)

This commit is contained in:
Intelli 2025-09-02 18:05:30 -06:00
parent 6155d4e864
commit 8b3e37774a
13 changed files with 622 additions and 45 deletions

View file

@ -1,5 +1,6 @@
package net.coreprotect.event;
import org.bukkit.Location;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
@ -9,16 +10,33 @@ public class CoreProtectPreLogEvent extends Event implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancelled = false;
private String user;
private Location location;
public CoreProtectPreLogEvent(String user, Location location) {
super(true); // async
this.user = user;
this.location = location;
}
/**
* Backwards-compatible constructor for API v10 and earlier.
* Defaults location to null; listeners expecting v10 signature can still subscribe.
*/
@Deprecated
public CoreProtectPreLogEvent(String user) {
super(true); // async
this.user = user;
this.location = null;
}
public String getUser() {
return user;
}
public Location getLocation() {
return location;
}
@Override
public boolean isCancelled() {
return cancelled;
@ -37,6 +55,14 @@ public class CoreProtectPreLogEvent extends Event implements Cancellable {
this.user = newUser;
}
public void setLocation(Location newLocation) {
if (newLocation == null) {
throw new IllegalArgumentException("Invalid location");
}
this.location = newLocation;
}
@Override
public HandlerList getHandlers() {
return handlers;