AlttdGriefPrevention/src/main/java/me/ryanhamshire/GriefPrevention/events/TrustChangedEvent.java

120 lines
2.7 KiB
Java
Raw Normal View History

2019-09-18 02:19:30 +00:00
package me.ryanhamshire.GriefPrevention.events;
import me.ryanhamshire.GriefPrevention.Claim;
import me.ryanhamshire.GriefPrevention.ClaimPermission;
2019-09-18 02:19:30 +00:00
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import java.util.ArrayList;
import java.util.List;
2019-09-18 02:19:30 +00:00
/**
* This event is thrown when the trust is changed in one or more claims
*
* @author roinujnosde
2019-09-18 02:19:30 +00:00
*/
public class TrustChangedEvent extends Event implements Cancellable
{
2019-09-18 02:19:30 +00:00
private static final HandlerList handlers = new HandlerList();
2019-09-18 02:19:30 +00:00
private final Player changer;
private final List<Claim> claims;
private final ClaimPermission claimPermission;
private final boolean given;
private final String identifier;
private boolean cancelled;
public TrustChangedEvent(Player changer, List<Claim> claims, ClaimPermission claimPermission, boolean given,
String identifier)
{
super();
this.changer = changer;
this.claims = claims;
this.claimPermission = claimPermission;
this.given = given;
this.identifier = identifier;
}
public TrustChangedEvent(Player changer, Claim claim, ClaimPermission claimPermission, boolean given, String identifier)
{
this.changer = changer;
claims = new ArrayList<>();
claims.add(claim);
this.claimPermission = claimPermission;
this.given = given;
this.identifier = identifier;
}
@Override
public HandlerList getHandlers()
{
return handlers;
}
2019-09-18 02:19:30 +00:00
/**
* Gets who made the change
*
* @return the changer
*/
public Player getChanger()
{
return changer;
}
2019-09-18 02:19:30 +00:00
/**
* Gets the changed claims
*
* @return the changed claims
*/
public List<Claim> getClaims()
{
return claims;
}
2019-09-18 02:19:30 +00:00
/**
* Gets the claim permission (null if the permission is being taken)
*
* @return the claim permission
*/
public ClaimPermission getClaimPermission()
{
return claimPermission;
}
2019-09-18 02:19:30 +00:00
/**
* Checks if the trust is being given
*
* @return true if given, false if taken
*/
public boolean isGiven()
{
return given;
}
2019-09-18 02:19:30 +00:00
/**
* Gets the identifier of the receiver of this action
* Can be: "public", "all", a UUID, a permission
*
* @return the identifier
*/
public String getIdentifier()
{
return identifier;
}
2019-09-18 02:19:30 +00:00
@Override
public boolean isCancelled()
{
return cancelled;
}
2019-09-18 02:19:30 +00:00
@Override
public void setCancelled(boolean cancelled)
{
this.cancelled = cancelled;
}
2019-09-18 02:19:30 +00:00
}