Skip to content

Commit

Permalink
Update API for new options.
Browse files Browse the repository at this point in the history
* Fix some missing javadocs.
  • Loading branch information
bloodmc committed Dec 30, 2019
1 parent 85fca61 commit 77a0a3f
Show file tree
Hide file tree
Showing 15 changed files with 146 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@

import com.griefdefender.api.User;

/**
* An event is fired when a {@link User} is attacked in a {@link Claim}.
*/
public interface AttackPlayerEvent extends ClaimEvent, Cancellable {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@

import org.checkerframework.checker.nullness.qual.Nullable;

/**
* An event that is fired when a {@link User} or entity crosses a {@link Claim} border.
*/
public interface BorderClaimEvent extends ClaimEvent, Cancellable {

/**
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/griefdefender/api/event/ClaimEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
import java.util.List;
import java.util.Optional;

/**
* Base event when one or more {@link Claim}s are affected.
*/
public interface ClaimEvent extends Event {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@
package com.griefdefender.api.event;

import com.griefdefender.api.Tristate;
import com.griefdefender.api.claim.Claim;
import com.griefdefender.api.permission.flag.Flag;

/**
* Base event when a {@link Flag} is changed in a {@link Claim}.
*/
public interface FlagPermissionEvent extends PermissionEvent {

interface ClearAll extends FlagPermissionEvent { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@

import java.util.List;

import com.griefdefender.api.claim.Claim;

/**
* An event that is fired when a {@link Group}'s trust changes in a {@link Claim}.
*/
public interface GroupTrustClaimEvent extends TrustClaimEvent {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@
*/
package com.griefdefender.api.event;

import com.griefdefender.api.claim.Claim;
import com.griefdefender.api.permission.option.Option;

/**
* Base event when a {@link Option} is changed in a {@link Claim}.
*/
public interface OptionPermissionEvent extends PermissionEvent {

interface ClearAll extends OptionPermissionEvent { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@

import net.kyori.event.Cancellable;

/**
* An event that is fired after a {@link Claim} has been removed.
*/
public interface RemoveClaimEvent extends ClaimEvent, Cancellable {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
*/
package com.griefdefender.api.event;


/**
* An event that is fired after a {@link Claim}'s data has been saved.
*/
public interface SaveClaimEvent extends ClaimEvent {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@

import java.util.UUID;

/**
* An event that is fired after a {@link Claim} has been transferred to a new owner.
*/
public interface TransferClaimEvent extends ClaimEvent {

UUID getOriginalOwner();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@
*/
package com.griefdefender.api.event;

import com.griefdefender.api.claim.Claim;
import com.griefdefender.api.claim.TrustType;
import net.kyori.event.Cancellable;

/**
* Base event that is fired when a {@link User}'s or {@link Group}'s trust changes in a {@link Claim}.
*/
public interface TrustClaimEvent extends ClaimEvent, Cancellable {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
import java.util.List;
import java.util.UUID;

import com.griefdefender.api.claim.Claim;

/**
* An event that is fired when a {@link User}'s trust changes in a {@link Claim}.
*/
public interface UserTrustClaimEvent extends TrustClaimEvent {

/**
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/com/griefdefender/api/permission/ContextKeys.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
*/
package com.griefdefender.api.permission;

import com.griefdefender.api.permission.option.Options;

public class ContextKeys {

/**
Expand Down Expand Up @@ -77,6 +79,22 @@ public class ContextKeys {
*/
public static final String FLAG = "gd_flag";

/**
* Represents a command {@link Option} context key.
*
* Used by options {@link Options#PLAYER_COMMAND_ENTER}
* and {@link Options#PLAYER_COMMAND_EXIT}.
*/
public static final String RUN_AS = "run_as";

/**
* Represents a command {@link Option} context key.
*
* Used by options {@link Options#PLAYER_COMMAND_ENTER}
* and {@link Options#PLAYER_COMMAND_EXIT}.
*/
public static final String RUN_FOR = "run_for";

/**
* Represents a {@link Flag} source context key.
*/
Expand Down
47 changes: 44 additions & 3 deletions src/main/java/com/griefdefender/api/permission/option/Option.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@

import com.griefdefender.api.CatalogType;
import com.griefdefender.api.GriefDefender;

import net.kyori.text.Component;

import java.util.Set;

public interface Option<T> extends CatalogType {

/**
Expand All @@ -40,6 +41,22 @@ public interface Option<T> extends CatalogType {
*/
boolean isGlobal();

/**
* Whether this option can support multiple values.
*
* @return <code>true</code> if the option supports
* multiple values.
* <code>false</code> otherwise.
*/
boolean multiValued();

/**
* A set of required context keys that must be set.
*
* @return An immutable set of required context keys
*/
Set<String> getRequiredContextKeys();

/**
* Gets the option permission.
*
Expand Down Expand Up @@ -93,13 +110,37 @@ interface Builder<T> {
Builder<T> id(String pluginId);

/**
* The flag name.
* The option name.
*
* @param flagName The flag name
* @param name The option name
* @return The builder
*/
Builder<T> name(String name);

/**
* The option description.
*
* @param description The option description
* @return The builder
*/
Builder<T> description(Component description);

/**
* Whether the option supports multiple values.
*
* @param multi True if multi, false otherwise
* @return The builder
*/
Builder<T> multiValued(boolean multi);

/**
* The required context keys.
*
* @param keys The context keys
* @return The builder
*/
Builder<T> requiredContextKeys(Set<String> keys);

/**
* Resets the builder to default settings.
*
Expand Down
57 changes: 42 additions & 15 deletions src/main/java/com/griefdefender/api/permission/option/Options.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
import com.griefdefender.api.permission.option.type.WeatherTypes;
import com.griefdefender.api.util.generator.DummyObjectProvider;

import java.util.List;

@SuppressWarnings("unchecked")
public final class Options {

Expand Down Expand Up @@ -91,7 +93,7 @@ public final class Options {
public static final Option<Integer> MIN_SIZE_Z = DummyObjectProvider.createFor(Option.class, "min-size-z");

/**
* Number of days after not paying taxes before an automatic chest claim will be frozen.
* Number of days after not paying taxes before a claim will be frozen.
*/
public static final Option<Integer> TAX_EXPIRATION = DummyObjectProvider.createFor(Option.class, "tax-expiration");

Expand Down Expand Up @@ -159,11 +161,6 @@ public final class Options {
*/
public static final Option<Integer> MIN_LEVEL = DummyObjectProvider.createFor(Option.class, "min-level");

/**
* The radius in blocks used to list nearby claims.
*/
public static final Option<Integer> RADIUS_LIST = DummyObjectProvider.createFor(Option.class, "radius-list");

/**
* The radius in blocks used to search for nearby claims while inspecting.
*/
Expand All @@ -175,12 +172,14 @@ public final class Options {
public static final Option<Boolean> RAID = DummyObjectProvider.createFor(Option.class, "raid");

/**
* The spawn limit for a specific set of {@link Context}'s in a claim.
* Used to determine the spawn limit for a specific set of {@link Context}'s in a claim.
*
* Note: Supports multiple values.
*/
public static final Option<Integer> SPAWN_LIMIT = DummyObjectProvider.createFor(Option.class, "spawn-limit");

/**
* Used for executing a command with specific {@link Context}'s.<br>
* Used for executing a command on {@link Claim} enter with specific {@link Context}'s.<br>
* Accepts the following placeholders :
* <ul>
* <li>%player%
Expand All @@ -191,7 +190,21 @@ public final class Options {
* <li>%location%
* </ul>
*/
public static final Option<String> PLAYER_COMMAND = DummyObjectProvider.createFor(Option.class, "player-command");
public static final Option<List<String>> PLAYER_COMMAND_ENTER = DummyObjectProvider.createFor(Option.class, "player-command-enter");

/**
* Used for executing a command on {@link Claim} exit with specific {@link Context}'s.<br>
* Accepts the following placeholders :
* <ul>
* <li>%player%
* <li>%owner%
* <li>%uuid%
* <li>%world%
* <li>%server%
* <li>%location%
* </ul>
*/
public static final Option<List<String>> PLAYER_COMMAND_EXIT = DummyObjectProvider.createFor(Option.class, "player-command-exit");

/**
* Used to determine if a player is unable to fly in a {@link Claim}.<br>
Expand Down Expand Up @@ -274,24 +287,38 @@ public final class Options {
/**
* Used to set a player's walk speed in a {@link Claim}.<br>
*
* Note: (-1 = undefined)
* Note: (-1.0 = undefined)
*/
public static final Option<Integer> PLAYER_WALK_SPEED = DummyObjectProvider.createFor(Option.class, "player-walk-speed");
public static final Option<Double> PLAYER_WALK_SPEED = DummyObjectProvider.createFor(Option.class, "player-walk-speed");

/**
* Used to a player's weather in a {@link Claim}.<br>
* Default supported types are :
* Used to set a player's weather in a {@link Claim}.<br>
* Accepts the following values :
* <ul>
* <li>{@link WeatherTypes#CLEAR}
* <li>{@link WeatherTypes#RAIN}
* <li>{@link WeatherTypes#DOWNFALL}
* <li>{@link WeatherTypes#UNDEFINED}
* </ul>
*/
public static final Option<WeatherType> PLAYER_WEATHER = DummyObjectProvider.createFor(Option.class, "player-weather");

/**
* Used to determine if a player can participate in player versus player combat.
* Used to determine if players can combat each other.
*/
public static final Option<Tristate> PVP = DummyObjectProvider.createFor(Option.class, "pvp");

/**
* Used to determine if a player can use commands during PvP combat.
*/
public static final Option<Boolean> PVP_COMBAT_COMMAND = DummyObjectProvider.createFor(Option.class, "pvp-combat-command");

/**
* Used to determine if a player can teleport during PvP combat.
*/
public static final Option<Boolean> PVP_COMBAT_TELEPORT = DummyObjectProvider.createFor(Option.class, "pvp-combat-teleport");

/**
* Used to determine how many seconds PvP combat is considered to continue after the most recent damage.
*/
public static final Option<Integer> PVP_COMBAT_TIMEOUT = DummyObjectProvider.createFor(Option.class, "pvp-combat-timeout");
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public class WeatherTypes {
public static final WeatherType CLEAR = DummyObjectProvider.createFor(WeatherType.class, "clear");

/**
* Represents a rain {@link WeatherType}.
* Represents a downfall {@link WeatherType}.
*/
public static final WeatherType RAIN = DummyObjectProvider.createFor(WeatherType.class, "rain");
public static final WeatherType DOWNFALL = DummyObjectProvider.createFor(WeatherType.class, "downfall");

/**
* Represents undefined {@link WeatherType}.
Expand Down

0 comments on commit 77a0a3f

Please sign in to comment.