Remove duplication of code for event
This commit is contained in:
parent
19565e90ff
commit
81e4dbefc5
|
@ -3,35 +3,30 @@ package world.bentobox.limits.events;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
import org.eclipse.jdt.annotation.NonNull;
|
import org.eclipse.jdt.annotation.NonNull;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
|
||||||
import world.bentobox.bentobox.api.events.BentoBoxEvent;
|
|
||||||
import world.bentobox.limits.Settings.EntityGroup;
|
import world.bentobox.limits.Settings.EntityGroup;
|
||||||
import world.bentobox.limits.objects.IslandBlockCount;
|
import world.bentobox.limits.objects.IslandBlockCount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fired when a player joins the server and before limit settings for their island are changed based
|
* Fired when a player joins the server and for each perm-based limit setting.
|
||||||
* on the player's permissions. If cancelled, no limit settings will be made.
|
* If cancelled, no limit settings will be made.
|
||||||
|
* Settings can be adjusted and will be used.
|
||||||
* @author tastybento
|
* @author tastybento
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class LimitsPermCheckEvent extends BentoBoxEvent implements Cancellable {
|
public class LimitsPermCheckEvent extends LimitsJoinPermCheckEvent {
|
||||||
|
|
||||||
private final Player player;
|
|
||||||
private final String islandId;
|
|
||||||
private IslandBlockCount ibc;
|
|
||||||
private boolean ignorePerms;
|
|
||||||
private boolean cancel;
|
|
||||||
private @Nullable EntityGroup entityGroup;
|
private @Nullable EntityGroup entityGroup;
|
||||||
private @Nullable EntityType entityType;
|
private @Nullable EntityType entityType;
|
||||||
private @Nullable Material material;
|
private @Nullable Material material;
|
||||||
private int value;
|
private int value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fired when a player joins the server and before limit settings for their island are changed based
|
* Fired when a player joins the server and for each perm-based limit setting.
|
||||||
* on the player's permissions. If cancelled, no limit settings will be made.
|
* If cancelled, no limit settings will be made.
|
||||||
|
* Settings can be adjusted and will be used.
|
||||||
* @param player - player joining
|
* @param player - player joining
|
||||||
* @param islandId - the unique island id.
|
* @param islandId - the unique island id.
|
||||||
* @param ibc - IslandBlockCount object for this island
|
* @param ibc - IslandBlockCount object for this island
|
||||||
|
@ -47,86 +42,13 @@ public class LimitsPermCheckEvent extends BentoBoxEvent implements Cancellable {
|
||||||
@Nullable EntityType entityType,
|
@Nullable EntityType entityType,
|
||||||
@Nullable Material material,
|
@Nullable Material material,
|
||||||
int value) {
|
int value) {
|
||||||
super();
|
super(player, islandId, ibc);
|
||||||
this.player = player;
|
|
||||||
this.islandId = islandId;
|
|
||||||
this.ibc = ibc;
|
|
||||||
this.entityGroup = entgroup;
|
this.entityGroup = entgroup;
|
||||||
this.entityType = entityType;
|
this.entityType = entityType;
|
||||||
this.material = material;
|
this.material = material;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the player joining
|
|
||||||
* @return the player
|
|
||||||
*/
|
|
||||||
@NonNull
|
|
||||||
public Player getPlayer() {
|
|
||||||
return player;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the unique island id. Use the islands manager to obtain the island
|
|
||||||
* @return the islandId
|
|
||||||
*/
|
|
||||||
@NonNull
|
|
||||||
public String getIslandId() {
|
|
||||||
return islandId;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the island block count
|
|
||||||
* @return the ibc
|
|
||||||
*/
|
|
||||||
@Nullable
|
|
||||||
public IslandBlockCount getIbc() {
|
|
||||||
return ibc;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the island block count to a specific setting
|
|
||||||
* @param ibc the ibc to set
|
|
||||||
*/
|
|
||||||
public void setIbc(@Nullable IslandBlockCount ibc) {
|
|
||||||
this.ibc = ibc;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCancelled() {
|
|
||||||
return this.cancel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCancelled(boolean cancel) {
|
|
||||||
this.cancel = cancel;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if player's perms should be considered or not
|
|
||||||
* @return the ignorePerms
|
|
||||||
*/
|
|
||||||
public boolean isIgnorePerms() {
|
|
||||||
return ignorePerms;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Ignore player's perms. This differs to canceling the event in that the IslandBlockCount will be used if given via
|
|
||||||
* {@link setIbc(IslandBlockCount ibc)}
|
|
||||||
* @param ignorePerms the ignorePerms to set
|
|
||||||
*/
|
|
||||||
public void setIgnorePerms(boolean ignorePerms) {
|
|
||||||
this.ignorePerms = ignorePerms;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the entityGroup
|
* @return the entityGroup
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -93,7 +93,7 @@ public class JoinListener implements Listener {
|
||||||
ibc = new IslandBlockCount(islandId, gameMode);
|
ibc = new IslandBlockCount(islandId, gameMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
int value = Integer.valueOf(split[4]);
|
int value = Integer.parseInt(split[4]);
|
||||||
// Fire perm check event
|
// Fire perm check event
|
||||||
LimitsPermCheckEvent l = new LimitsPermCheckEvent(player, gameMode, ibc, entgroup, et, m, value);
|
LimitsPermCheckEvent l = new LimitsPermCheckEvent(player, gameMode, ibc, entgroup, et, m, value);
|
||||||
Bukkit.getPluginManager().callEvent(l);
|
Bukkit.getPluginManager().callEvent(l);
|
||||||
|
|
Loading…
Reference in New Issue