-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds event that fires when player joins and before perm check
Cancel the event to prevent perm settings of limits.
- Loading branch information
1 parent
caf7664
commit ad18695
Showing
4 changed files
with
128 additions
and
5 deletions.
There are no files selected for viewing
110 changes: 110 additions & 0 deletions
110
src/main/java/world/bentobox/limits/events/LimitsJoinPermCheckEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
package world.bentobox.limits.events; | ||
|
||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.Cancellable; | ||
import org.eclipse.jdt.annotation.NonNull; | ||
import org.eclipse.jdt.annotation.Nullable; | ||
|
||
import world.bentobox.bentobox.api.events.BentoBoxEvent; | ||
import world.bentobox.limits.objects.IslandBlockCount; | ||
|
||
/** | ||
* Fired when a player joins the server and before limit settings for their island are changed based | ||
* on the player's permissions. If cancelled, no limit settings will be made. | ||
* @author tastybento | ||
* | ||
*/ | ||
public class LimitsJoinPermCheckEvent extends BentoBoxEvent implements Cancellable { | ||
|
||
private final Player player; | ||
private final String islandId; | ||
private IslandBlockCount ibc; | ||
private boolean cancel; | ||
private boolean ignorePerms; | ||
|
||
/** | ||
* Fired when a player joins the server and before limit settings for their island are changed based | ||
* on the player's permissions. If cancelled, no limit settings will be made. | ||
* @param player - player joining | ||
* @param islandId - the unique island id. | ||
* @param ibc - IslandBlockCount object for this island | ||
*/ | ||
public LimitsJoinPermCheckEvent(@NonNull Player player, @NonNull String islandId, @Nullable IslandBlockCount ibc) { | ||
super(); | ||
this.player = player; | ||
this.islandId = islandId; | ||
this.ibc = ibc; | ||
} | ||
|
||
|
||
/** | ||
* 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 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; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters