├── .gitignore ├── README.md ├── build.gradle.kts ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── jitpack.yml └── src └── main └── java └── me └── angeschossen └── lands └── api ├── LandsIntegration.java ├── blockworks ├── BlockCoordinate.java ├── BoundingBox.java └── ChunkCoordinate.java ├── configuration ├── Configuration.java ├── MainConfig.java └── modules │ ├── ModuleConfig.java │ ├── NationsConfig.java │ └── WarsConfig.java ├── events ├── BroadcastEvent.java ├── ChunkDeleteEvent.java ├── ChunkPostClaimEvent.java ├── ChunkPreClaimEvent.java ├── LandBanPlayerEvent.java ├── LandChatEvent.java ├── LandCreateEvent.java ├── LandDeleteEvent.java ├── LandInvitePlayerEvent.java ├── LandOwnerChangeEvent.java ├── LandRenameEvent.java ├── LandTrustPlayerEvent.java ├── LandUnbanPlayerEvent.java ├── LandUntrustPlayerEvent.java ├── PlayerLeaveLandEvent.java ├── land │ ├── DeleteReason.java │ ├── LandCancellableEvent.java │ ├── LandConvertEvent.java │ ├── LandEvent.java │ ├── LandPostCreateEvent.java │ ├── bank │ │ ├── BankEvent.java │ │ ├── LandBankBalanceChangedEvent.java │ │ ├── LandBankDepositEvent.java │ │ └── LandBankWithdrawEvent.java │ ├── block │ │ ├── LandBlockEvent.java │ │ ├── LandBlockInteractEvent.java │ │ ├── LandBlockPlaceEvent.java │ │ └── LandBlockRemoveEvent.java │ ├── claiming │ │ ├── LandMergeEvent.java │ │ ├── LandUnclaimAllEvent.java │ │ ├── LandUnclaimSelectionEvent.java │ │ └── selection │ │ │ ├── LandClaimSelectionEvent.java │ │ │ ├── LandUnclaimSelectionEvent.java │ │ │ └── SelectionEvent.java │ ├── member │ │ ├── LandEditMemberCancellableEvent.java │ │ └── LandEditMemberEvent.java │ └── spawn │ │ ├── LandSpawnRemoveEvent.java │ │ ├── LandSpawnSetEvent.java │ │ └── LandSpawnTeleportEvent.java ├── memberholder │ ├── InboxMessageReceivedEvent.java │ ├── MemberHolderEvent.java │ ├── MemberHolderLevelChangedEvent.java │ ├── MemberHolderRelationChangeEvent.java │ └── MemberHolderUpkeepEvent.java ├── nation │ ├── edit │ │ ├── NationCreateEvent.java │ │ ├── NationDeleteEvent.java │ │ ├── NationEditEvent.java │ │ └── NationRenameEvent.java │ └── member │ │ ├── NationEditMemberCancellableEvent.java │ │ ├── NationEditMemberEvent.java │ │ ├── NationTrustLandEvent.java │ │ └── NationUntrustLandEvent.java ├── player │ ├── PlayerEvent.java │ ├── PlayerLandEvent.java │ ├── PlayerNullableEvent.java │ ├── area │ │ ├── PlayerAreaEnterEvent.java │ │ ├── PlayerAreaEvent.java │ │ └── PlayerAreaLeaveEvent.java │ ├── database │ │ └── PlayerDataLoadedEvent.java │ ├── economy │ │ └── PlayerTaxEvent.java │ ├── role │ │ └── PlayerToggleRoleFlagEvent.java │ └── teleportation │ │ ├── PlayerRandomTeleportEvent.java │ │ └── PlayerSpawnLandEvent.java ├── plugin │ ├── LandsEvent.java │ └── TargetableEvent.java ├── rent │ ├── PlayerRentalEvent.java │ ├── RentalEvent.java │ ├── RentalExpireEvent.java │ └── RentalOfferCreateEvent.java ├── role │ └── RoleEvent.java └── war │ ├── WarDeclareEvent.java │ ├── WarEndEvent.java │ ├── WarEvent.java │ ├── WarStartEvent.java │ └── captureflag │ ├── CaptureFlagBreakEvent.java │ ├── CaptureFlagCapturedEvent.java │ ├── CaptureFlagProgressEvent.java │ └── base │ ├── CaptureFlagCancellableEvent.java │ └── CaptureFlagEvent.java ├── exceptions ├── FlagConflictException.java ├── LandAlreadyInNationException.java └── ManagedByDifferentHolderException.java ├── flags ├── DefaultStateFlag.java ├── Flag.java ├── FlagRegistry.java ├── Flags.java ├── enums │ ├── FlagModule.java │ ├── FlagTarget.java │ └── RoleFlagCategory.java ├── type │ ├── Flags.java │ ├── NaturalFlag.java │ ├── PlayerFlag.java │ ├── RoleFlag.java │ └── parent │ │ ├── DefaultStateFlag.java │ │ └── Flag.java └── types │ ├── LandFlag.java │ ├── NationRoleFlag.java │ ├── PlayerFlag.java │ └── RoleFlag.java ├── handler ├── APIHandler.java ├── FlagFactory.java ├── LandsIntegrationFactory.java └── MessageHandler.java ├── holders └── BalanceHolder.java ├── inbox ├── InboxCategory.java ├── InboxMessage.java └── InboxMessageProvider.java ├── integration └── LandsIntegration.java ├── items └── ItemType.java ├── land ├── Area.java ├── ChunkCoordinate.java ├── Container.java ├── Land.java ├── LandArea.java ├── LandCategory.java ├── LandWorld.java ├── SystemFlagStatesHolder.java ├── TaxHolder.java ├── block │ ├── LandBlock.java │ ├── LandBlockType.java │ ├── LandMainBlock.java │ └── removalreason │ │ ├── BlockRemovalReason.java │ │ └── LandBlockRemovalReason.java ├── enums │ ├── LandGetMode.java │ ├── LandSetting.java │ ├── LandType.java │ ├── SettingMode.java │ └── SortMode.java └── rental │ ├── InfoType.java │ └── offer │ ├── base │ ├── AcceptedRentalOfferBase.java │ ├── RentalBase.java │ └── RentalOfferBase.java │ └── types │ ├── RentOffer.java │ ├── RentalType.java │ ├── RentedState.java │ ├── SellOffer.java │ └── SoldState.java ├── legacy └── LandsIntegrator.java ├── levels ├── Level.java ├── LevelsHandler.java ├── Requirement.java ├── attribute │ ├── LevelAttribute.java │ └── impl │ │ ├── ChunksAttribute.java │ │ ├── EffectsAmountAttribute.java │ │ ├── EffectsAttribute.java │ │ └── UpkeepAttribute.java └── requirement │ ├── CachedRequirement.java │ └── Requirement.java ├── memberholder ├── CMDTarget.java ├── HolderType.java └── MemberHolder.java ├── membershiprequest ├── LandMemberShipRequest.java ├── MemberShipRequest.java └── NationMemberShipRequest.java ├── nation ├── Nation.java └── invite │ └── NationInvite.java ├── player ├── LandPlayer.java ├── OfflinePlayer.java ├── PlayerCooldown.java ├── Selection.java ├── TrustedPlayer.java ├── Visualization.java ├── chat │ └── ChatMode.java ├── claiming │ └── ClaimResult.java ├── combat │ └── CombatTag.java └── invite │ ├── Invite.java │ ├── InviteIntent.java │ ├── result │ ├── InviteResult.java │ ├── MergeRequestResult.java │ └── TrustResult.java │ └── type │ ├── MergeRequest.java │ ├── OwnerInvite.java │ └── TrustInvite.java ├── relations ├── Relation.java └── RelationRequest.java ├── role ├── Role.java ├── RoleHolder.java ├── enums │ ├── EditPlayerResponse.java │ └── RoleType.java └── system │ └── SystemFlagStates.java ├── sorting ├── Sorting.java └── SortingContext.java ├── utils └── PlayerUtils.java └── war ├── ActiveWarStats.java ├── War.java ├── WarState.java ├── WarStats.java ├── captureflag └── CaptureFlag.java ├── declaration ├── MutualDeclaration.java └── WarDeclaration.java ├── enums ├── WarResult.java ├── WarSetting.java ├── WarStatus.java └── WarTeam.java ├── player └── WarPlayer.java └── storage └── WarHandler.java /.gitignore: -------------------------------------------------------------------------------- 1 | # Project exclude paths 2 | /target/ 3 | /.idea/ 4 | /build 5 | /src/main/java/me/angeschossen/lands/api/events/PlayerLanguageChangeEvent.java -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Wiki 2 | [https://wiki.incredibleplugins.com/lands/developer-api/api](https://wiki.incredibleplugins.com/lands/developers/api) 3 | -------------------------------------------------------------------------------- /build.gradle.kts: -------------------------------------------------------------------------------- 1 | group = "com.github.angeschossen" 2 | version = "7.15.20" 3 | description = "LandsAPI" 4 | 5 | plugins { 6 | `java-library` 7 | id("io.github.goooler.shadow").version("8.1.8") 8 | `maven-publish` 9 | } 10 | 11 | repositories { 12 | mavenCentral() 13 | mavenLocal() 14 | 15 | maven { 16 | url = uri("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") 17 | 18 | // As of Gradle 5.1, you can limit this to only those 19 | // dependencies you expect from it 20 | content { 21 | includeGroup("org.bukkit") 22 | includeGroup("org.spigotmc") 23 | } 24 | } 25 | 26 | /* 27 | As Spigot-API depends on the BungeeCord ChatComponent-API, 28 | we need to add the Sonatype OSS repository, as Gradle, 29 | in comparison to maven, doesn't want to understand the ~/.m2 30 | directory unless added using mavenLocal(). Maven usually just gets 31 | it from there, as most people have run the BuildTools at least once. 32 | This is therefore not needed if you're using the full Spigot/CraftBukkit, 33 | or if you're using the Bukkit API. 34 | */ 35 | maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") } 36 | maven { url = uri("https://oss.sonatype.org/content/repositories/central") } 37 | maven { url = uri("https://jitpack.io") } 38 | } 39 | 40 | tasks.withType { 41 | options.encoding = "UTF-8" 42 | } 43 | 44 | java { 45 | toolchain.languageVersion.set(JavaLanguageVersion.of(17)) 46 | } 47 | 48 | tasks { 49 | java { 50 | withJavadocJar() 51 | } 52 | 53 | build { 54 | dependsOn(shadowJar) 55 | } 56 | 57 | shadowJar { 58 | archiveClassifier.set("") // replace default 59 | configurations = listOf(project.configurations.shadow.get()) 60 | relocate("com.github.angeschossen.pluginframework.api", "me.angeschossen.lands.api.framework") 61 | relocate("com.github.angeschossen.applicationframework.api", "me.angeschossen.lands.api.applicationframework") 62 | } 63 | } 64 | 65 | dependencies { 66 | shadow("com.github.Angeschossen:PluginFrameworkAPI:1.1.7") 67 | shadow("com.github.Angeschossen:ApplicationFrameworkAPI:1.0.2") 68 | compileOnly("org.spigotmc:spigot-api:1.21.1-R0.1-SNAPSHOT") 69 | compileOnly("org.realityforge.org.jetbrains.annotations:org.jetbrains.annotations:1.7.0") 70 | } 71 | 72 | publishing { 73 | publications { 74 | create("maven") { 75 | groupId = project.group.toString() 76 | artifactId = project.description 77 | version = project.version.toString() 78 | 79 | from(components["java"]) 80 | } 81 | } 82 | } -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IncrediblePlugins/LandsAPI/30e7e5af3287f0e27007c3282cb95094c243bb00/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip 4 | networkTimeout=10000 5 | zipStoreBase=GRADLE_USER_HOME 6 | zipStorePath=wrapper/dists 7 | -------------------------------------------------------------------------------- /jitpack.yml: -------------------------------------------------------------------------------- 1 | jdk: 2 | - openjdk17 3 | before_install: 4 | - sdk install java 17.0.1-open 5 | - sdk use java 17.0.1-open -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/blockworks/BlockCoordinate.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.blockworks; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.World; 5 | import org.bukkit.entity.Player; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | public interface BlockCoordinate { 9 | @NotNull World getWorld(); 10 | 11 | int getX(); 12 | 13 | int getY(); 14 | 15 | int getZ(); 16 | 17 | int getChunkX(); 18 | 19 | int getChunkZ(); 20 | 21 | double getDistance(@NotNull Player player); 22 | 23 | Location toLocation(); 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/blockworks/BoundingBox.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.blockworks; 2 | 3 | import org.bukkit.World; 4 | import org.jetbrains.annotations.NotNull; 5 | 6 | public interface BoundingBox { 7 | @NotNull 8 | BlockCoordinate getMax(); 9 | 10 | @NotNull BlockCoordinate getMiddle(); 11 | 12 | @NotNull 13 | BlockCoordinate getMin(); 14 | 15 | boolean contains(int x, int y, int z); 16 | 17 | /** 18 | * Same as {@link #contains(int, int, int)}, but ignores y values. 19 | * 20 | * @param x Block coordinate X 21 | * @param z Block coordinate Z 22 | * @return true, if the boundingBox contains these coordinates. 23 | */ 24 | boolean contains(int x, int z); 25 | 26 | @NotNull 27 | World getWorld(); 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/blockworks/ChunkCoordinate.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.blockworks; 2 | 3 | import java.util.Objects; 4 | 5 | public class ChunkCoordinate implements me.angeschossen.lands.api.land.ChunkCoordinate { 6 | 7 | public final int x, z; 8 | private final int hashcode; 9 | 10 | public ChunkCoordinate(int x, int z) { 11 | this.x = x; 12 | this.z = z; 13 | this.hashcode = Objects.hash(x, z); 14 | } 15 | 16 | @Override 17 | public boolean equals(Object object) { 18 | if (!(object instanceof me.angeschossen.lands.api.land.ChunkCoordinate)) { 19 | return false; 20 | } 21 | 22 | me.angeschossen.lands.api.land.ChunkCoordinate c = (me.angeschossen.lands.api.land.ChunkCoordinate) object; 23 | return c.getX() == x && c.getZ() == z; 24 | } 25 | 26 | public int getBlockX() { 27 | return getX() << 4; 28 | } 29 | 30 | public int getBlockZ() { 31 | return getZ() << 4; 32 | } 33 | 34 | public int getX() { 35 | return x; 36 | } 37 | 38 | public int getZ() { 39 | return z; 40 | } 41 | 42 | @Override 43 | public int hashCode() { 44 | return hashcode; 45 | } 46 | 47 | @Override 48 | public String toString() { 49 | return "ChunkCoordinate{x=" + x + ",z=" + z + "}"; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/configuration/Configuration.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.configuration; 2 | 3 | import me.angeschossen.lands.api.configuration.modules.NationsConfig; 4 | import me.angeschossen.lands.api.configuration.modules.WarsConfig; 5 | import org.jetbrains.annotations.NotNull; 6 | 7 | public interface Configuration { 8 | /** 9 | * Get configuration options for wars. 10 | * 11 | * @return never null 12 | */ 13 | @NotNull 14 | WarsConfig getWarsModuleConfig(); 15 | 16 | /** 17 | * Get configuration options for nations. 18 | * 19 | * @return never null 20 | */ 21 | @NotNull 22 | NationsConfig getNationsModuleConfig(); 23 | 24 | /** 25 | * Get the main configuration options. 26 | * 27 | * @return never null 28 | */ 29 | @NotNull 30 | MainConfig getMainConfig(); 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/configuration/MainConfig.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.configuration; 2 | 3 | import com.github.angeschossen.pluginframework.api.configuration.Configuration; 4 | 5 | /** 6 | * Config for config.yml 7 | */ 8 | public interface MainConfig extends Configuration { 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/configuration/modules/ModuleConfig.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.configuration.modules; 2 | 3 | import com.github.angeschossen.pluginframework.api.configuration.Configuration; 4 | 5 | /** 6 | * Interface for module configs such as wars and nations. 7 | */ 8 | public interface ModuleConfig extends Configuration { 9 | 10 | /** 11 | * Modules such as wars and nations can be disabled. 12 | * 13 | * @return true, if this module is disabled 14 | */ 15 | boolean isEnabled(); 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/configuration/modules/NationsConfig.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.configuration.modules; 2 | 3 | /** 4 | * Config for nations.yml 5 | */ 6 | public interface NationsConfig extends ModuleConfig { 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/configuration/modules/WarsConfig.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.configuration.modules; 2 | 3 | import org.bukkit.Material; 4 | import org.jetbrains.annotations.NotNull; 5 | 6 | import java.util.Set; 7 | 8 | /** 9 | * Config for nations.yml 10 | */ 11 | public interface WarsConfig extends ModuleConfig { 12 | /** 13 | * Get collection of placeable blocks during a war inside a land that is taking part in the war. 14 | * @return never null 15 | */ 16 | @NotNull 17 | SetgetBlockPlaceList(); 18 | 19 | /** 20 | * Get collection of breakable blocks during a war inside a land that is taking part in the war. 21 | * @return never null 22 | */ 23 | @NotNull 24 | Set getBlockBreakList(); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/ChunkPostClaimEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events; 2 | 3 | import com.github.angeschossen.pluginframework.api.utils.Checks; 4 | import me.angeschossen.lands.api.events.land.LandEvent; 5 | import me.angeschossen.lands.api.land.Land; 6 | import me.angeschossen.lands.api.land.LandWorld; 7 | import me.angeschossen.lands.api.player.LandPlayer; 8 | import org.bukkit.event.HandlerList; 9 | import org.jetbrains.annotations.NotNull; 10 | import org.jetbrains.annotations.Nullable; 11 | 12 | /** 13 | * Called after claiming a chunk. 14 | */ 15 | public class ChunkPostClaimEvent extends LandEvent { 16 | 17 | public static HandlerList handlerList = new HandlerList(); 18 | 19 | private final int x, z; 20 | private final @NotNull LandWorld world; 21 | 22 | public ChunkPostClaimEvent(@Nullable LandPlayer landPlayer, @NotNull Land land, @NotNull LandWorld landWorld, int x, int z) { 23 | super(land, landPlayer); 24 | 25 | Checks.requireNonNull(landWorld, "landWorld"); 26 | this.x = x; 27 | this.world = landWorld; 28 | this.z = z; 29 | } 30 | 31 | public static HandlerList getHandlerList() { 32 | return handlerList; 33 | } 34 | 35 | /** 36 | * Get chunk z. 37 | * 38 | * @return chunk z 39 | */ 40 | public int getZ() { 41 | return z; 42 | } 43 | 44 | /** 45 | * Get the world in which the chunk is located in. 46 | * 47 | * @return world 48 | */ 49 | @NotNull 50 | public LandWorld getWorld() { 51 | return world; 52 | } 53 | 54 | /** 55 | * Get chunk x. 56 | * 57 | * @return chunk x 58 | */ 59 | public int getX() { 60 | return x; 61 | } 62 | 63 | @Override 64 | public @NotNull HandlerList getHandlers() { 65 | return handlerList; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/ChunkPreClaimEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events; 2 | 3 | import com.github.angeschossen.pluginframework.api.utils.Checks; 4 | import me.angeschossen.lands.api.events.land.LandEvent; 5 | import me.angeschossen.lands.api.land.Land; 6 | import me.angeschossen.lands.api.land.LandWorld; 7 | import me.angeschossen.lands.api.player.LandPlayer; 8 | import org.bukkit.event.Cancellable; 9 | import org.bukkit.event.HandlerList; 10 | import org.jetbrains.annotations.NotNull; 11 | import org.jetbrains.annotations.Nullable; 12 | 13 | /** 14 | * Called before a chunk is being claimed. 15 | */ 16 | public class ChunkPreClaimEvent extends LandEvent implements Cancellable { 17 | 18 | public static HandlerList handlerList = new HandlerList(); 19 | private final int x; 20 | private final int z; 21 | private final @NotNull LandWorld world; 22 | private boolean cancelled; 23 | 24 | public ChunkPreClaimEvent(@NotNull Land land, @Nullable LandPlayer landPlayer, @NotNull LandWorld world, int x, int z) { 25 | super(land, landPlayer); 26 | 27 | Checks.requireNonNull(world, "world"); 28 | this.world = world; 29 | this.x = x; 30 | this.z = z; 31 | } 32 | 33 | public static HandlerList getHandlerList() { 34 | return handlerList; 35 | } 36 | 37 | /** 38 | * Get chunk x. 39 | * 40 | * @return chunk x 41 | */ 42 | public int getX() { 43 | return x; 44 | } 45 | 46 | /** 47 | * Get chunk z. 48 | * 49 | * @return chunk z 50 | */ 51 | public int getZ() { 52 | return z; 53 | } 54 | 55 | /** 56 | * Use {@link #getWorld()} instead. 57 | * 58 | * @return world name 59 | */ 60 | @Deprecated 61 | @NotNull 62 | public String getWorldName() { 63 | return world.getName(); 64 | } 65 | 66 | /** 67 | * Get the world in which the chunk is located in. 68 | * 69 | * @return world in which the chunk is located 70 | */ 71 | @NotNull 72 | public LandWorld getWorld() { 73 | return world; 74 | } 75 | 76 | @Override 77 | public boolean isCancelled() { 78 | return this.cancelled; 79 | } 80 | 81 | @Override 82 | public void setCancelled(boolean cancelled) { 83 | this.cancelled = cancelled; 84 | } 85 | 86 | @Override 87 | public @NotNull HandlerList getHandlers() { 88 | return handlerList; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/LandBanPlayerEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events; 2 | 3 | import me.angeschossen.lands.api.events.land.member.LandEditMemberCancellableEvent; 4 | import me.angeschossen.lands.api.land.Area; 5 | import me.angeschossen.lands.api.land.Land; 6 | import org.bukkit.event.HandlerList; 7 | import org.jetbrains.annotations.NotNull; 8 | import org.jetbrains.annotations.Nullable; 9 | 10 | import java.util.UUID; 11 | 12 | /** 13 | * Called whenver a land bans a player from a land or an area. 14 | * This also untrusts the player, if they were previously trusted. 15 | */ 16 | public class LandBanPlayerEvent extends LandEditMemberCancellableEvent { 17 | 18 | public static HandlerList handlerList = new HandlerList(); 19 | 20 | /** 21 | * Create an instance of this event. 22 | * 23 | * @param land the land 24 | * @param area if null, the target is banned from the whole land. Otherwise, only from the area. 25 | * @param initiator the player that initiated the ban 26 | * @param targetUUID the taget that is getting banned 27 | */ 28 | public LandBanPlayerEvent(@NotNull Land land, @Nullable Area area, @NotNull UUID initiator, @NotNull UUID targetUUID) { 29 | super(land, area, initiator, targetUUID); 30 | } 31 | 32 | public static HandlerList getHandlerList() { 33 | return handlerList; 34 | } 35 | 36 | @Override 37 | public @NotNull HandlerList getHandlers() { 38 | return handlerList; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/LandCreateEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events; 2 | 3 | import me.angeschossen.lands.api.events.land.LandEvent; 4 | import me.angeschossen.lands.api.land.Land; 5 | import me.angeschossen.lands.api.player.LandPlayer; 6 | import org.bukkit.event.Cancellable; 7 | import org.bukkit.event.HandlerList; 8 | import org.jetbrains.annotations.NotNull; 9 | import org.jetbrains.annotations.Nullable; 10 | 11 | import java.util.UUID; 12 | 13 | public class LandCreateEvent extends LandEvent implements Cancellable { 14 | 15 | public static HandlerList handlerList = new HandlerList(); 16 | private boolean cancelled; 17 | 18 | /** 19 | * Create an instance of this event. 20 | * 21 | * @param landPlayer The player that initiated the creation. If null, the creation wasn't initiated by a player. 22 | * @param land the land that is being created 23 | */ 24 | public LandCreateEvent(@Nullable LandPlayer landPlayer, @NotNull Land land) { 25 | super(land, landPlayer); 26 | } 27 | 28 | 29 | /** 30 | * Create an instance of this event. 31 | * 32 | * @param playerUUID The player that initiated the creation. If null, the creation wasn't initiated by a player. 33 | * @param land the land that is being created 34 | */ 35 | public LandCreateEvent(@Nullable UUID playerUUID, @NotNull Land land) { 36 | super(land, playerUUID); 37 | } 38 | 39 | 40 | public static HandlerList getHandlerList() { 41 | return handlerList; 42 | } 43 | 44 | @Override 45 | public boolean isCancelled() { 46 | return this.cancelled; 47 | } 48 | 49 | @Override 50 | public void setCancelled(boolean cancelled) { 51 | this.cancelled = cancelled; 52 | } 53 | 54 | @Override 55 | public @NotNull HandlerList getHandlers() { 56 | return handlerList; 57 | } 58 | 59 | @Override 60 | public String toString() { 61 | return "LandCreateEvent{" + 62 | "land=" + land.toString() + 63 | "}"; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/LandInvitePlayerEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events; 2 | 3 | import me.angeschossen.lands.api.events.land.member.LandEditMemberCancellableEvent; 4 | import me.angeschossen.lands.api.land.Area; 5 | import me.angeschossen.lands.api.land.Land; 6 | import org.bukkit.event.HandlerList; 7 | import org.jetbrains.annotations.NotNull; 8 | import org.jetbrains.annotations.Nullable; 9 | 10 | import java.util.UUID; 11 | 12 | /** 13 | * Called whenver a land invites a player to the whole land or a specific area inside that land. 14 | */ 15 | public class LandInvitePlayerEvent extends LandEditMemberCancellableEvent { 16 | public static HandlerList handlerList = new HandlerList(); 17 | 18 | /** 19 | * Create an instance of this event. 20 | * 21 | * @param land the land that invites the player 22 | * @param area if null, the player is invited to a specific area only 23 | * @param initiator The player that initiated the invitation. If null, a player didn't initiate the invitation. 24 | * @param targetUUID the player that is being invited 25 | */ 26 | public LandInvitePlayerEvent(@NotNull Land land, @Nullable Area area, @Nullable UUID initiator, @NotNull UUID targetUUID) { 27 | super(land, area, initiator, targetUUID); 28 | } 29 | 30 | public static HandlerList getHandlerList() { 31 | return handlerList; 32 | } 33 | 34 | @Override 35 | public @NotNull HandlerList getHandlers() { 36 | return handlerList; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/LandTrustPlayerEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events; 2 | 3 | import me.angeschossen.lands.api.events.land.member.LandEditMemberCancellableEvent; 4 | import me.angeschossen.lands.api.land.Area; 5 | import me.angeschossen.lands.api.land.Land; 6 | import org.bukkit.event.HandlerList; 7 | import org.jetbrains.annotations.NotNull; 8 | import org.jetbrains.annotations.Nullable; 9 | 10 | import java.util.UUID; 11 | 12 | /** 13 | * Called when a land trusts a players. 14 | * Depending on the servers config, invites are enabled. 15 | * If invites are enabled, this event is called whenever a player accepts an invitation to join a land. 16 | * If invites are disabled, players are trusted directly and the event is called at the command execution or menu action that trusts the player. 17 | */ 18 | public class LandTrustPlayerEvent extends LandEditMemberCancellableEvent { 19 | public static HandlerList handlerList = new HandlerList(); 20 | 21 | /** 22 | * Create an instance of this event. 23 | * @param land the land 24 | * @param area If null, the player is trusted to the whole land. Otherwise, only to the specified area. 25 | * @param initiator The player that trusted the target. If null, no player initiated this action. 26 | * @param targetUUID the target that is being trusted 27 | */ 28 | public LandTrustPlayerEvent(@NotNull Land land, @Nullable Area area, @Nullable UUID initiator, @NotNull UUID targetUUID) { 29 | super(land, area, initiator, targetUUID); 30 | } 31 | 32 | public static HandlerList getHandlerList() { 33 | return handlerList; 34 | } 35 | 36 | @Override 37 | public @NotNull HandlerList getHandlers() { 38 | return handlerList; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/LandUnbanPlayerEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events; 2 | 3 | import me.angeschossen.lands.api.events.land.member.LandEditMemberCancellableEvent; 4 | import me.angeschossen.lands.api.land.Area; 5 | import me.angeschossen.lands.api.land.Land; 6 | import org.bukkit.event.HandlerList; 7 | import org.jetbrains.annotations.NotNull; 8 | import org.jetbrains.annotations.Nullable; 9 | 10 | import java.util.UUID; 11 | 12 | /** 13 | * Called whenever a land unbans a player from the whole land or a specific area. 14 | */ 15 | public class LandUnbanPlayerEvent extends LandEditMemberCancellableEvent { 16 | 17 | public static HandlerList handlerList = new HandlerList(); 18 | 19 | /** 20 | * Create an instance of this event. 21 | * 22 | * @param land the land that the player is being unbanned from 23 | * @param area If null, the player is unbanned from the whole land. Otherwise, only from the specified area. 24 | * @param initiator The player that initiated the target getting unbanned. If null, no player initiated this action. 25 | * @param targetUUID the player that is being unabnned 26 | */ 27 | public LandUnbanPlayerEvent(@NotNull Land land, @Nullable Area area, @Nullable UUID initiator, @NotNull UUID targetUUID) { 28 | super(land, area, initiator, targetUUID); 29 | } 30 | 31 | public static HandlerList getHandlerList() { 32 | return handlerList; 33 | } 34 | 35 | @Override 36 | public @NotNull HandlerList getHandlers() { 37 | return handlerList; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/LandUntrustPlayerEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events; 2 | 3 | import me.angeschossen.lands.api.events.land.member.LandEditMemberCancellableEvent; 4 | import me.angeschossen.lands.api.land.Area; 5 | import me.angeschossen.lands.api.land.Land; 6 | import org.bukkit.event.HandlerList; 7 | import org.jetbrains.annotations.NotNull; 8 | import org.jetbrains.annotations.Nullable; 9 | 10 | import java.util.UUID; 11 | 12 | /** 13 | * Called whenever a land untrusts a player from the whole land or from a specific area. 14 | */ 15 | public class LandUntrustPlayerEvent extends LandEditMemberCancellableEvent { 16 | 17 | public static HandlerList handlerList = new HandlerList(); 18 | private final @NotNull 19 | UntrustReason reason; 20 | 21 | /** 22 | * Create an instance of this event. 23 | * 24 | * @param land land from which the target is untrusted 25 | * @param area If null, the target is being untrusted from the whole land. Otherwise, only from the specified area. 26 | * @param initiator The player that initiated untrusting the player. If null, no player initiated this action. 27 | * @param targetUUID the player that is being untrusted 28 | * @param reason the reason of the player being untrusted 29 | */ 30 | public LandUntrustPlayerEvent(@NotNull Land land, @Nullable Area area, @Nullable UUID initiator, @NotNull UUID targetUUID, @NotNull UntrustReason reason) { 31 | super(land, area, initiator, targetUUID); 32 | 33 | this.reason = reason; 34 | } 35 | 36 | public static HandlerList getHandlerList() { 37 | return handlerList; 38 | } 39 | 40 | /** 41 | * Get the reason of the player being untrusted. 42 | * 43 | * @return never null 44 | */ 45 | @NotNull 46 | public UntrustReason getReason() { 47 | return reason; 48 | } 49 | 50 | @Override 51 | public void setCancelled(boolean cancelled) { 52 | if (reason != UntrustReason.BAN) { 53 | super.setCancelled(cancelled); 54 | } 55 | } 56 | 57 | @Override 58 | public @NotNull 59 | HandlerList getHandlers() { 60 | return handlerList; 61 | } 62 | 63 | 64 | public enum UntrustReason { 65 | /** 66 | * Untrust command or untrust action in menu was triggered by a player. 67 | */ 68 | DEFAULT, 69 | /** 70 | * The player is being banned. Banning a player, also untrusts them. 71 | */ 72 | BAN, 73 | /** 74 | * The player wasn't able to pay its taxes. 75 | */ 76 | TAXES, 77 | /** 78 | * The player was a tenant and his rental expired. 79 | */ 80 | RENTAL_EXPIRED 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/PlayerLeaveLandEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events; 2 | 3 | import me.angeschossen.lands.api.events.player.PlayerLandEvent; 4 | import me.angeschossen.lands.api.land.Area; 5 | import me.angeschossen.lands.api.land.Land; 6 | import me.angeschossen.lands.api.player.LandPlayer; 7 | import org.bukkit.event.HandlerList; 8 | import org.jetbrains.annotations.NotNull; 9 | import org.jetbrains.annotations.Nullable; 10 | 11 | /** 12 | * Called whenver a land leaves the whole land. 13 | */ 14 | public class PlayerLeaveLandEvent extends PlayerLandEvent { 15 | 16 | public static HandlerList handlerList = new HandlerList(); 17 | 18 | /** 19 | * Create an instance of this event. 20 | * @param land land that the player is leaving 21 | * @param area If null, the player is leaving the whole land. Otherwise, only the specified area. 22 | * @param landPlayer the player that is leaving 23 | */ 24 | public PlayerLeaveLandEvent(@NotNull Land land, @Nullable Area area, @NotNull LandPlayer landPlayer) { 25 | super(land, area, landPlayer); 26 | } 27 | 28 | public static HandlerList getHandlerList() { 29 | return handlerList; 30 | } 31 | 32 | @Override 33 | public @NotNull HandlerList getHandlers() { 34 | return handlerList; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/land/DeleteReason.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.land; 2 | 3 | import me.angeschossen.lands.api.events.ChunkDeleteEvent; 4 | import me.angeschossen.lands.api.events.LandDeleteEvent; 5 | 6 | /** 7 | * Delete reasons are used at the {@link ChunkDeleteEvent} and {@link LandDeleteEvent}. 8 | */ 9 | public enum DeleteReason { 10 | /** 11 | * Used at command execution through player or when 3rd party plugins didn't specify a delete-reason. 12 | */ 13 | DEFAULT, 14 | /** 15 | * Used by 3rd party plugins. 16 | */ 17 | PLUGIN, 18 | /** 19 | * Deletion because of insufficient funds. 20 | */ 21 | UPKEEP, 22 | /** 23 | * Forcefully deletion triggered by a server admin via a cmd. 24 | */ 25 | ADMIN, 26 | /** 27 | * A land is deleted because of inactivity of the owner. 28 | */ 29 | INACTIVITY, 30 | /** 31 | * Land was captured by their enemy during war. 32 | */ 33 | WAR_CAPTURED, 34 | /** 35 | * A temporary camp has expired. 36 | */ 37 | CAMP_EXPIRED, 38 | /** 39 | * A land with no claims was automatically deleted. 40 | * Servers can disable this in config. 41 | */ 42 | NO_CLAIMS 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/land/LandCancellableEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.land; 2 | 3 | import me.angeschossen.lands.api.land.Land; 4 | import me.angeschossen.lands.api.player.LandPlayer; 5 | import org.bukkit.event.Cancellable; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | /** 9 | * Used for events that involve a land and can be cancelled. 10 | */ 11 | public abstract class LandCancellableEvent extends LandEvent implements Cancellable { 12 | 13 | private boolean cancelled; 14 | 15 | /** 16 | * Constructor for this event. 17 | * @param land involved land 18 | * @param landPlayer involved player 19 | */ 20 | public LandCancellableEvent(@NotNull Land land, LandPlayer landPlayer) { 21 | super(land, landPlayer); 22 | } 23 | 24 | @Override 25 | public boolean isCancelled() { 26 | return cancelled; 27 | } 28 | 29 | @Override 30 | public void setCancelled(boolean cancel) { 31 | this.cancelled = cancel; 32 | } 33 | } -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/land/LandConvertEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.land; 2 | 3 | import com.google.common.collect.ImmutableMap; 4 | import me.angeschossen.lands.api.land.Land; 5 | import me.angeschossen.lands.api.land.enums.LandType; 6 | import me.angeschossen.lands.api.player.LandPlayer; 7 | import org.bukkit.event.Cancellable; 8 | import org.bukkit.event.HandlerList; 9 | import org.jetbrains.annotations.NotNull; 10 | import org.jetbrains.annotations.Nullable; 11 | 12 | /** 13 | * Called each time a land is converted into an admin land or back into a player land. 14 | * 15 | * @see LandType 16 | */ 17 | public class LandConvertEvent extends LandEvent implements Cancellable { 18 | public static HandlerList handlerList = new HandlerList(); 19 | private final @NotNull LandType landType; 20 | private boolean cancelled; 21 | 22 | /** 23 | * Create an instance of this event. 24 | * 25 | * @param land land that is about to converted into a different type 26 | * @param landPlayer The player that triggered this conversion. 27 | * if null this is initiated by the plugin itself. 28 | * @param landType Type into which the land is about to be converted into 29 | */ 30 | public LandConvertEvent(@NotNull Land land, @Nullable LandPlayer landPlayer, @NotNull LandType landType) { 31 | super(land, landPlayer); 32 | 33 | this.landType = landType; 34 | } 35 | 36 | public static HandlerList getHandlerList() { 37 | return handlerList; 38 | } 39 | 40 | @Override 41 | public HandlerList getHandlers() { 42 | return handlerList; 43 | } 44 | 45 | @Override 46 | public void setExpressionVariables(ImmutableMap.@NotNull Builder builder) { 47 | super.setExpressionVariables(builder); 48 | 49 | builder.put("type", landType); 50 | } 51 | 52 | /** 53 | * Get the new land type that the land is about to get converted into 54 | * @return never null 55 | */ 56 | @NotNull 57 | public LandType getLandType() { 58 | return landType; 59 | } 60 | 61 | @Override 62 | public boolean isCancelled() { 63 | return cancelled; 64 | } 65 | 66 | @Override 67 | public void setCancelled(boolean b) { 68 | this.cancelled = b; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/land/LandEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.land; 2 | 3 | import com.github.angeschossen.pluginframework.api.utils.Checks; 4 | import com.google.common.collect.ImmutableMap; 5 | import me.angeschossen.lands.api.events.player.PlayerNullableEvent; 6 | import me.angeschossen.lands.api.land.Land; 7 | import me.angeschossen.lands.api.player.LandPlayer; 8 | import org.jetbrains.annotations.NotNull; 9 | import org.jetbrains.annotations.Nullable; 10 | 11 | import java.util.Collection; 12 | import java.util.UUID; 13 | 14 | /** 15 | * Used for events that involve a land. 16 | */ 17 | public abstract class LandEvent extends PlayerNullableEvent { 18 | 19 | protected final @NotNull Land land; 20 | 21 | /** 22 | * Constructor for this event. 23 | * 24 | * @param land involved land 25 | * @param landPlayer involved player 26 | */ 27 | public LandEvent(@NotNull Land land, @Nullable LandPlayer landPlayer) { 28 | super(landPlayer); 29 | 30 | Checks.requireNonNull(land, "land"); 31 | this.land = land; 32 | } 33 | 34 | /** 35 | * Constructor for this event. 36 | * 37 | * @param land involved land 38 | * @param landPlayer The involved player, which might be offline. 39 | */ 40 | public LandEvent(@NotNull Land land, UUID landPlayer) { 41 | super(landPlayer); 42 | 43 | this.land = land; 44 | } 45 | 46 | /** 47 | * Get the involved land. 48 | * 49 | * @return never null 50 | */ 51 | @NotNull 52 | public Land getLand() { 53 | return land; 54 | } 55 | 56 | @Override 57 | public void setAffectedPlayers(ImmutableMap.@NotNull Builder> builder) { 58 | super.setAffectedPlayers(builder); 59 | 60 | land.setAffectedPlayers("land_", builder); 61 | } 62 | 63 | @Override 64 | public void setExpressionVariables(ImmutableMap.@NotNull Builder builder) { 65 | super.setExpressionVariables(builder); 66 | 67 | land.setExpressionVariables("land_", builder, getPlayerUID()); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/land/LandPostCreateEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.land; 2 | 3 | import me.angeschossen.lands.api.land.Land; 4 | import me.angeschossen.lands.api.player.LandPlayer; 5 | import org.bukkit.event.HandlerList; 6 | import org.jetbrains.annotations.NotNull; 7 | import org.jetbrains.annotations.Nullable; 8 | 9 | import java.util.UUID; 10 | 11 | /** 12 | * Called after land creation. At this stage the land received its ID. 13 | * If you don't need to ID and want to cancel land creation, use {@link me.angeschossen.lands.api.events.LandCreateEvent} instead. 14 | */ 15 | public class LandPostCreateEvent extends LandEvent { 16 | 17 | public static HandlerList handlerList = new HandlerList(); 18 | 19 | /** 20 | * Create an instance of this event. 21 | * 22 | * @param landPlayer The player that initiated the creation. If null, the creation wasn't initiated by a player. 23 | * @param land the land that is being created 24 | */ 25 | public LandPostCreateEvent(@Nullable LandPlayer landPlayer, @NotNull Land land) { 26 | super(land, landPlayer); 27 | } 28 | 29 | /** 30 | * Create an instance of this event. 31 | * 32 | * @param playerUUID The player that initiated the creation. If null, the creation wasn't initiated by a player. 33 | * @param land the land that is being created 34 | */ 35 | public LandPostCreateEvent(@Nullable UUID playerUUID, @NotNull Land land) { 36 | super(land, playerUUID); 37 | } 38 | 39 | public static HandlerList getHandlerList() { 40 | return handlerList; 41 | } 42 | 43 | @Override 44 | public @NotNull HandlerList getHandlers() { 45 | return handlerList; 46 | } 47 | 48 | 49 | @Override 50 | public String toString() { 51 | return "LandCreateEvent{" + 52 | "land=" + land.toString() + 53 | "}"; 54 | } 55 | 56 | @Override 57 | public @Nullable String getLogInfo() { 58 | return toString(); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/land/bank/BankEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.land.bank; 2 | 3 | import com.google.common.collect.ImmutableMap; 4 | import me.angeschossen.lands.api.events.land.LandEvent; 5 | import me.angeschossen.lands.api.land.Land; 6 | import me.angeschossen.lands.api.player.LandPlayer; 7 | import org.bukkit.event.Cancellable; 8 | import org.jetbrains.annotations.NotNull; 9 | import org.jetbrains.annotations.Nullable; 10 | 11 | /** 12 | * Used for all events that involve a land's bank. 13 | */ 14 | public abstract class BankEvent extends LandEvent implements Cancellable { 15 | private boolean cancelled = false; 16 | protected final double value; 17 | 18 | /** 19 | * Create an instance. 20 | * @param land the land that the bank belongs to 21 | * @param landPlayer The player that is involded. For example at "/lands deposit" 22 | * @param value can be negative 23 | */ 24 | public BankEvent(@NotNull Land land, @Nullable LandPlayer landPlayer, double value) { 25 | super(land, landPlayer); 26 | this.value = value; 27 | } 28 | 29 | /** 30 | * Get the modification value. 31 | * @return can be negative 32 | */ 33 | public final double getValue() { 34 | return value; 35 | } 36 | 37 | @Override 38 | public final boolean isCancelled() { 39 | return cancelled; 40 | } 41 | 42 | @Override 43 | public final void setCancelled(boolean cancelled) { 44 | this.cancelled = cancelled; 45 | } 46 | 47 | @Override 48 | public void setExpressionVariables(ImmutableMap.@NotNull Builder builder) { 49 | super.setExpressionVariables(builder); 50 | 51 | builder.put("value", value); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/land/bank/LandBankBalanceChangedEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.land.bank; 2 | 3 | import com.google.common.collect.ImmutableMap; 4 | import me.angeschossen.lands.api.events.land.LandEvent; 5 | import me.angeschossen.lands.api.land.Land; 6 | import me.angeschossen.lands.api.player.LandPlayer; 7 | import org.bukkit.event.HandlerList; 8 | import org.jetbrains.annotations.NotNull; 9 | 10 | /** 11 | * Called every time the bank balance changed. For example, if the land pays upkeep or claims chunks etc. 12 | * This also includes {@link LandBankDepositEvent} and {@link LandBankWithdrawEvent}. 13 | * This event isn't cancellable. You can only cancel the previously mentioned deposit and withdraw events. 14 | */ 15 | public class LandBankBalanceChangedEvent extends LandEvent { 16 | 17 | public static final HandlerList handlerList = new HandlerList(); 18 | private final double prev, now; 19 | 20 | /** 21 | * Create an instance of this event. 22 | * @param land land to which the bank belongs to 23 | * @param prev previous balance 24 | * @param now new balance 25 | */ 26 | public LandBankBalanceChangedEvent(@NotNull Land land, double prev, double now) { 27 | super(land, (LandPlayer) null); 28 | 29 | this.prev = prev; 30 | this.now = now; 31 | } 32 | 33 | /** 34 | * Get the new balance 35 | * @return The new balance. Never negative 36 | */ 37 | public double getNow() { 38 | return now; 39 | } 40 | 41 | /** 42 | * Get the previous balance 43 | * @return The previous balance. Never negative 44 | */ 45 | public double getPrevious() { 46 | return prev; 47 | } 48 | 49 | @Override 50 | public void setExpressionVariables(ImmutableMap.@NotNull Builder builder) { 51 | super.setExpressionVariables(builder); 52 | 53 | builder.put("previous", prev) 54 | .put("now", now); 55 | } 56 | 57 | public static HandlerList getHandlerList() { 58 | return handlerList; 59 | } 60 | 61 | @Override 62 | public HandlerList getHandlers() { 63 | return handlerList; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/land/bank/LandBankDepositEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.land.bank; 2 | 3 | import me.angeschossen.lands.api.land.Land; 4 | import me.angeschossen.lands.api.player.LandPlayer; 5 | import org.bukkit.event.Cancellable; 6 | import org.bukkit.event.HandlerList; 7 | import org.jetbrains.annotations.NotNull; 8 | import org.jetbrains.annotations.Nullable; 9 | 10 | /** 11 | * Called whenever a player deposits money in the land bank. 12 | */ 13 | public class LandBankDepositEvent extends BankEvent implements Cancellable { 14 | public static final HandlerList handlerList = new HandlerList(); 15 | 16 | /** 17 | * Create an instance of this event. 18 | * 19 | * @param land land to which this bank belongs to 20 | * @param landPlayer player that deposits money 21 | * @param value deposited value 22 | */ 23 | public LandBankDepositEvent(@NotNull Land land, @NotNull LandPlayer landPlayer, double value) { 24 | super(land, landPlayer, value); 25 | } 26 | 27 | public static HandlerList getHandlerList() { 28 | return handlerList; 29 | } 30 | 31 | @Override 32 | public HandlerList getHandlers() { 33 | return handlerList; 34 | } 35 | 36 | @Override 37 | public String toString() { 38 | return "LandBankDepositEvent{" + 39 | "land=" + land.toString() + 40 | ",value=" + value + 41 | "}"; 42 | } 43 | 44 | @Override 45 | public @Nullable String getLogInfo() { 46 | return toString(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/land/bank/LandBankWithdrawEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.land.bank; 2 | 3 | import me.angeschossen.lands.api.land.Land; 4 | import me.angeschossen.lands.api.player.LandPlayer; 5 | import org.bukkit.event.Cancellable; 6 | import org.bukkit.event.HandlerList; 7 | import org.jetbrains.annotations.NotNull; 8 | import org.jetbrains.annotations.Nullable; 9 | 10 | /** 11 | * Called whenever a player withdraws money from the bank. 12 | */ 13 | public class LandBankWithdrawEvent extends BankEvent implements Cancellable { 14 | public static final HandlerList handlerList = new HandlerList(); 15 | 16 | /** 17 | * Create an instance of this event. 18 | * 19 | * @param land land to which the bank belongs 20 | * @param landPlayer player which withdraws money 21 | * @param value the value that is about to withdrawn 22 | */ 23 | public LandBankWithdrawEvent(@NotNull Land land, @NotNull LandPlayer landPlayer, double value) { 24 | super(land, landPlayer, value); 25 | } 26 | 27 | public static HandlerList getHandlerList() { 28 | return handlerList; 29 | } 30 | 31 | @Override 32 | public String toString() { 33 | return "LandBankWithdrawEvent{" + 34 | "land=" + land.toString() + 35 | ",value=" + value + 36 | "}"; 37 | } 38 | 39 | @Override 40 | public @Nullable String getLogInfo() { 41 | return toString(); 42 | } 43 | 44 | @Override 45 | public HandlerList getHandlers() { 46 | return handlerList; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/land/block/LandBlockEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.land.block; 2 | 3 | import me.angeschossen.lands.api.events.land.LandEvent; 4 | import me.angeschossen.lands.api.land.Land; 5 | import me.angeschossen.lands.api.land.block.LandBlock; 6 | import me.angeschossen.lands.api.player.LandPlayer; 7 | import org.bukkit.event.Cancellable; 8 | import org.jetbrains.annotations.NotNull; 9 | import org.jetbrains.annotations.Nullable; 10 | 11 | public abstract class LandBlockEvent extends LandEvent implements Cancellable { 12 | 13 | protected final @NotNull LandBlock landBlock; 14 | protected boolean cancelled; 15 | 16 | public LandBlockEvent(@NotNull Land land, @Nullable LandPlayer landPlayer, @NotNull LandBlock landBlock) { 17 | super(land, landPlayer); 18 | this.landBlock = landBlock; 19 | } 20 | 21 | @Override 22 | public boolean isCancelled() { 23 | return cancelled; 24 | } 25 | 26 | @Override 27 | public void setCancelled(boolean cancel) { 28 | this.cancelled = cancel; 29 | } 30 | 31 | @NotNull 32 | public final LandBlock getLandBlock() { 33 | return landBlock; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/land/block/LandBlockInteractEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.land.block; 2 | 3 | import me.angeschossen.lands.api.land.Land; 4 | import me.angeschossen.lands.api.land.block.LandBlock; 5 | import me.angeschossen.lands.api.player.LandPlayer; 6 | import org.bukkit.event.HandlerList; 7 | import org.jetbrains.annotations.NotNull; 8 | import org.jetbrains.annotations.Nullable; 9 | 10 | /** 11 | * Called whenever a player interacts with a mainblock or caputeflag etc. 12 | * Landblock types: {@link me.angeschossen.lands.api.land.block.LandBlockType} 13 | */ 14 | public class LandBlockInteractEvent extends LandBlockEvent { 15 | public static final HandlerList handlerList = new HandlerList(); 16 | 17 | public LandBlockInteractEvent(@NotNull Land land, @Nullable LandPlayer landPlayer, @NotNull LandBlock landBlock) { 18 | super(land, landPlayer, landBlock); 19 | } 20 | 21 | public static HandlerList getHandlerList() { 22 | return handlerList; 23 | } 24 | 25 | @Override 26 | public @NotNull HandlerList getHandlers() { 27 | return handlerList; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/land/block/LandBlockPlaceEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.land.block; 2 | 3 | import me.angeschossen.lands.api.land.block.LandBlock; 4 | import me.angeschossen.lands.api.land.block.LandBlockType; 5 | import me.angeschossen.lands.api.player.LandPlayer; 6 | import org.bukkit.event.HandlerList; 7 | import org.jetbrains.annotations.NotNull; 8 | import org.jetbrains.annotations.Nullable; 9 | 10 | /** 11 | * Called when a land block is placed. This will also be fired for the auto placed mainblock at land creation. 12 | * Landblock types: {@link me.angeschossen.lands.api.land.block.LandBlockType} 13 | */ 14 | public class LandBlockPlaceEvent extends LandBlockEvent { 15 | public static final HandlerList handlerList = new HandlerList(); 16 | 17 | /** 18 | * Create an instance of this event. 19 | * 20 | * @param landPlayer player that placed the landblock. If null, no player is involved. 21 | * @param landBlock landblock that is being placed 22 | */ 23 | public LandBlockPlaceEvent(@Nullable LandPlayer landPlayer, @NotNull LandBlock landBlock) { 24 | super(landBlock.getContainer().getLand(), landPlayer, landBlock); 25 | } 26 | 27 | public static HandlerList getHandlerList() { 28 | return handlerList; 29 | } 30 | 31 | @Override 32 | public @NotNull HandlerList getHandlers() { 33 | return handlerList; 34 | } 35 | 36 | /** 37 | * Cancel the placement of this landblock. 38 | * 39 | * @param cancel true if you wish to cancel this event 40 | * @throws IllegalStateException placements of rental signs can't be cancelled. See {@link LandBlockType#RENTAL} 41 | */ 42 | @Override 43 | public void setCancelled(boolean cancel) { 44 | if (landBlock.getType() == LandBlockType.RENTAL) { 45 | throw new IllegalStateException("Can't cancel landblock placement of type " + LandBlockType.RENTAL.toString()); 46 | } 47 | super.setCancelled(cancel); 48 | } 49 | 50 | @Override 51 | public String toString() { 52 | return "LandBlockPlaceEvent{" + 53 | "block=" + landBlock.toString() + 54 | "}"; 55 | } 56 | 57 | @Override 58 | public @Nullable String getLogInfo() { 59 | return toString(); 60 | } 61 | } -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/land/claiming/LandMergeEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.land.claiming; 2 | 3 | import com.github.angeschossen.pluginframework.api.utils.Checks; 4 | import me.angeschossen.lands.api.events.land.LandCancellableEvent; 5 | import me.angeschossen.lands.api.land.Land; 6 | import me.angeschossen.lands.api.player.LandPlayer; 7 | import org.bukkit.event.HandlerList; 8 | import org.jetbrains.annotations.NotNull; 9 | 10 | /** 11 | * Called when a land owner accepts a merge request. 12 | */ 13 | public class LandMergeEvent extends LandCancellableEvent { 14 | public static HandlerList handlerList = new HandlerList(); 15 | private final @NotNull Land toMerge; 16 | 17 | /** 18 | * Constructor for this event. 19 | * 20 | * @param requester involved land 21 | * @param landPlayer involved player 22 | */ 23 | public LandMergeEvent(@NotNull Land requester, @NotNull Land toMerge, LandPlayer landPlayer) { 24 | super(requester, landPlayer); 25 | 26 | this.toMerge = Checks.requireNonNull(toMerge, "mergedLand"); 27 | } 28 | 29 | /** 30 | * Get the merged land. 31 | * 32 | * @return land that gets merged into {@link #getLand()} 33 | */ 34 | public @NotNull Land getToMerge() { 35 | return toMerge; 36 | } 37 | 38 | @Override 39 | public @NotNull HandlerList getHandlers() { 40 | return handlerList; 41 | } 42 | 43 | public static HandlerList getHandlerList() { 44 | return handlerList; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/land/claiming/LandUnclaimAllEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.land.claiming; 2 | 3 | import me.angeschossen.lands.api.events.land.LandEvent; 4 | import me.angeschossen.lands.api.land.Land; 5 | import me.angeschossen.lands.api.player.LandPlayer; 6 | import org.bukkit.event.Cancellable; 7 | import org.bukkit.event.HandlerList; 8 | import org.jetbrains.annotations.NotNull; 9 | import org.jetbrains.annotations.Nullable; 10 | 11 | /** 12 | * Called whenever all claims are unclaimed at once for a land. 13 | * Usually the case when a player executes "/lands unclaim all". 14 | */ 15 | public class LandUnclaimAllEvent extends LandEvent implements Cancellable { 16 | public static HandlerList handlerList = new HandlerList(); 17 | private boolean cancelled; 18 | 19 | /** 20 | * Create an instance of this event. 21 | * @param land land from which all claims are about the be unclaimed 22 | * @param landPlayer involved player. Usually the player that executed "/lands unclaim all" 23 | */ 24 | public LandUnclaimAllEvent(@NotNull Land land, @Nullable LandPlayer landPlayer) { 25 | super(land, landPlayer); 26 | } 27 | 28 | public static HandlerList getHandlerList() { 29 | return handlerList; 30 | } 31 | 32 | @Override 33 | public HandlerList getHandlers() { 34 | return handlerList; 35 | } 36 | 37 | @Override 38 | public boolean isCancelled() { 39 | return cancelled; 40 | } 41 | 42 | @Override 43 | public void setCancelled(boolean b) { 44 | this.cancelled = b; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/land/claiming/LandUnclaimSelectionEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.land.claiming; 2 | 3 | import me.angeschossen.lands.api.events.land.claiming.selection.SelectionEvent; 4 | import me.angeschossen.lands.api.land.Land; 5 | import me.angeschossen.lands.api.player.LandPlayer; 6 | import me.angeschossen.lands.api.player.Selection; 7 | import org.bukkit.event.HandlerList; 8 | import org.jetbrains.annotations.NotNull; 9 | import org.jetbrains.annotations.Nullable; 10 | 11 | import java.util.Set; 12 | 13 | /** 14 | * Use {@link me.angeschossen.lands.api.events.land.claiming.selection.LandUnclaimSelectionEvent} instead. 15 | */ 16 | @Deprecated 17 | public class LandUnclaimSelectionEvent extends SelectionEvent { 18 | public static HandlerList handlerList = new HandlerList(); 19 | 20 | /** 21 | * Create an instance of this event. 22 | * 23 | * @param land land for which the selection is about to become unclaimed 24 | * @param landPlayer player that triggered the selection unclaim 25 | * @param selection the selection to be unclaimed 26 | * @param unclaim the collection of chunks that are going to be unclaimed. 27 | * In contrast to {@link Selection#getChunks()} this doesn't include already unclaimed chunks etc. 28 | */ 29 | public LandUnclaimSelectionEvent(@NotNull Land land, @Nullable LandPlayer landPlayer, @NotNull Selection selection, @NotNull Set unclaim) { 30 | super(land, landPlayer, selection, unclaim); 31 | } 32 | 33 | public static HandlerList getHandlerList() { 34 | return handlerList; 35 | } 36 | 37 | @Override 38 | public @NotNull HandlerList getHandlers() { 39 | return handlerList; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/land/claiming/selection/LandClaimSelectionEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.land.claiming.selection; 2 | 3 | import me.angeschossen.lands.api.land.Land; 4 | import me.angeschossen.lands.api.player.LandPlayer; 5 | import me.angeschossen.lands.api.player.Selection; 6 | import org.bukkit.event.HandlerList; 7 | import org.jetbrains.annotations.NotNull; 8 | import org.jetbrains.annotations.Nullable; 9 | 10 | import java.util.Set; 11 | 12 | /** 13 | * Called whenever a selection of chunks is claimed for a land. 14 | * This usally involves a player executing entering the selection mode ({@link Selection}) and selecting a rectangle of chunks. 15 | */ 16 | public class LandClaimSelectionEvent extends SelectionEvent { 17 | public static HandlerList handlerList = new HandlerList(); 18 | 19 | /** 20 | * Create an instance of this event. 21 | * 22 | * @param land land for which the selection is about to become claimed 23 | * @param landPlayer player that triggered the selection claim 24 | * @param selection the selection to be claimed 25 | * @param affectedChunks the collection of chunks that are going to be claimed. 26 | * In contrast to {@link Selection#getChunks()} this doesn't include already claimed chunks etc. 27 | */ 28 | public LandClaimSelectionEvent(@NotNull Land land, @Nullable LandPlayer landPlayer, @NotNull Selection selection, @NotNull Set affectedChunks) { 29 | super(land, landPlayer, selection, affectedChunks); 30 | } 31 | 32 | public static HandlerList getHandlerList() { 33 | return handlerList; 34 | } 35 | 36 | @Override 37 | public @NotNull HandlerList getHandlers() { 38 | return handlerList; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/land/claiming/selection/LandUnclaimSelectionEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.land.claiming.selection; 2 | 3 | import me.angeschossen.lands.api.land.Land; 4 | import me.angeschossen.lands.api.player.LandPlayer; 5 | import me.angeschossen.lands.api.player.Selection; 6 | import org.bukkit.event.HandlerList; 7 | import org.jetbrains.annotations.NotNull; 8 | import org.jetbrains.annotations.Nullable; 9 | 10 | import java.util.Set; 11 | 12 | /** 13 | * Called whenever a selection of chunks is unclaimed from a land. 14 | * This usally involves a player executing entering the selection mode ({@link Selection}) and selecting a rectangle of chunks. 15 | */ 16 | public class LandUnclaimSelectionEvent extends SelectionEvent { 17 | public static HandlerList handlerList = new HandlerList(); 18 | 19 | /** 20 | * Create an instance of this event. 21 | * 22 | * @param land land for which the selection is about to become unclaimed 23 | * @param landPlayer player that triggered the selection unclaim 24 | * @param selection the selection to be unclaimed 25 | * @param unclaim the collection of chunks that are going to be unclaimed. 26 | * In contrast to {@link Selection#getChunks()} this doesn't include already unclaimed chunks etc. 27 | */ 28 | public LandUnclaimSelectionEvent(@NotNull Land land, @Nullable LandPlayer landPlayer, @NotNull Selection selection, @NotNull Set unclaim) { 29 | super(land, landPlayer, selection, unclaim); 30 | } 31 | 32 | public static HandlerList getHandlerList() { 33 | return handlerList; 34 | } 35 | 36 | @Override 37 | public @NotNull HandlerList getHandlers() { 38 | return handlerList; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/land/member/LandEditMemberCancellableEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.land.member; 2 | 3 | import me.angeschossen.lands.api.land.Area; 4 | import me.angeschossen.lands.api.land.Land; 5 | import org.bukkit.event.Cancellable; 6 | import org.jetbrains.annotations.NotNull; 7 | import org.jetbrains.annotations.Nullable; 8 | 9 | import java.util.UUID; 10 | 11 | /** 12 | * Used for events that involve managing a member and that can be cancelled. 13 | */ 14 | public abstract class LandEditMemberCancellableEvent extends LandEditMemberEvent implements Cancellable { 15 | 16 | private boolean cancelled; 17 | 18 | /** 19 | * Constructor for this event. 20 | * 21 | * @param land land that manages this member 22 | * @param area if null, this action affects the whole land. If not null, this action is only executed for this single area. 23 | * @param initiator player that initiated this action 24 | * @param target member that this action affects 25 | */ 26 | public LandEditMemberCancellableEvent(@NotNull Land land, @Nullable Area area, @Nullable UUID initiator, @NotNull UUID target) { 27 | super(land, area, initiator, target); 28 | } 29 | 30 | @Override 31 | public boolean isCancelled() { 32 | return this.cancelled; 33 | } 34 | 35 | @Override 36 | public void setCancelled(boolean cancelled) { 37 | this.cancelled = cancelled; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/land/spawn/LandSpawnRemoveEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.land.spawn; 2 | 3 | import com.github.angeschossen.pluginframework.api.blockutil.UnloadedPosition; 4 | import me.angeschossen.lands.api.events.LandDeleteEvent; 5 | import me.angeschossen.lands.api.events.land.LandEvent; 6 | import me.angeschossen.lands.api.land.Land; 7 | import me.angeschossen.lands.api.player.LandPlayer; 8 | import org.bukkit.event.HandlerList; 9 | import org.jetbrains.annotations.NotNull; 10 | import org.jetbrains.annotations.Nullable; 11 | 12 | /** 13 | * This event is called each time the spawn is removed. 14 | * It mostly fires when an admin deletes world data or the world, in which the spawn was located 15 | * in doesn't exist any longer. This is not called upon land deletion. 16 | * If you want to handle this case too, just listen to {@link LandDeleteEvent}. 17 | */ 18 | public class LandSpawnRemoveEvent extends LandEvent { 19 | public static HandlerList handlerList = new HandlerList(); 20 | private final UnloadedPosition current; 21 | 22 | /** 23 | * Create an instance of this event. 24 | * 25 | * @param land land to which the current spawn belongs 26 | * @param landPlayer The player that removes this spawn. 27 | * If null, the spawn is being removed by the plugin itself. 28 | * @param current current spawn that is being removed 29 | */ 30 | public LandSpawnRemoveEvent(@NotNull Land land, @Nullable LandPlayer landPlayer, @NotNull UnloadedPosition current) { 31 | super(land, landPlayer); 32 | 33 | this.current = current; 34 | } 35 | 36 | public static HandlerList getHandlerList() { 37 | return handlerList; 38 | } 39 | 40 | /** 41 | * Get the current spawn. 42 | * 43 | * @return location of the spawn 44 | */ 45 | @NotNull 46 | public UnloadedPosition getCurrent() { 47 | return current; 48 | } 49 | 50 | @Override 51 | public HandlerList getHandlers() { 52 | return handlerList; 53 | } 54 | } -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/land/spawn/LandSpawnSetEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.land.spawn; 2 | 3 | import com.github.angeschossen.pluginframework.api.blockutil.UnloadedPosition; 4 | import com.google.common.collect.ImmutableMap; 5 | import me.angeschossen.lands.api.events.land.LandCancellableEvent; 6 | import me.angeschossen.lands.api.land.Land; 7 | import me.angeschossen.lands.api.player.LandPlayer; 8 | import org.bukkit.event.HandlerList; 9 | import org.jetbrains.annotations.NotNull; 10 | import org.jetbrains.annotations.Nullable; 11 | 12 | import java.util.Objects; 13 | 14 | /** 15 | * This even is called each time the spawn of a land changes. 16 | */ 17 | public class LandSpawnSetEvent extends LandCancellableEvent { 18 | public static HandlerList handlerList = new HandlerList(); 19 | private final @NotNull UnloadedPosition location; 20 | 21 | /** 22 | * Create an instance of this event. 23 | * 24 | * @param land land to which this spawn belongs 25 | * @param landPlayer player which sets this spawn. 26 | * if null, the spawn is set by the plugin itself 27 | * @param location the new spawn 28 | */ 29 | public LandSpawnSetEvent(@NotNull Land land, @Nullable LandPlayer landPlayer, @NotNull UnloadedPosition location) { 30 | super(land, landPlayer); 31 | 32 | Objects.requireNonNull(location, "spawn location can't be null"); 33 | this.location = location; 34 | } 35 | 36 | /** 37 | * Get the new location of the spawn. 38 | * 39 | * @return the new spawn location 40 | */ 41 | @NotNull 42 | public UnloadedPosition getNew() { 43 | return location; 44 | } 45 | 46 | /** 47 | * Get the old spawn. 48 | * 49 | * @return null, if previously none was set 50 | */ 51 | @Nullable 52 | public UnloadedPosition getCurrent() { 53 | return land.getSpawnPosition(); 54 | } 55 | 56 | public static HandlerList getHandlerList() { 57 | return handlerList; 58 | } 59 | 60 | @Override 61 | public HandlerList getHandlers() { 62 | return handlerList; 63 | } 64 | 65 | @Override 66 | public void setExpressionVariables(ImmutableMap.@NotNull Builder builder) { 67 | super.setExpressionVariables(builder); 68 | 69 | builder.put("world", location.getWorldName()) 70 | .put("x", location.getBlockX()) 71 | .put("y", location.getBlockY()) 72 | .put("z", location.getBlockZ()); 73 | } 74 | } -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/land/spawn/LandSpawnTeleportEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.land.spawn; 2 | 3 | import me.angeschossen.lands.api.events.land.LandEvent; 4 | import me.angeschossen.lands.api.land.Land; 5 | import me.angeschossen.lands.api.player.LandPlayer; 6 | import org.bukkit.event.Cancellable; 7 | import org.bukkit.event.HandlerList; 8 | import org.jetbrains.annotations.NotNull; 9 | 10 | import java.util.Objects; 11 | 12 | public class LandSpawnTeleportEvent extends LandEvent implements Cancellable { 13 | public static HandlerList handlerList = new HandlerList(); 14 | private boolean cancelled; 15 | 16 | /** 17 | * Create an instance of this event. 18 | * 19 | * @param land land to which the spawn belongs 20 | * @param landPlayer player that teleports to the spawn 21 | */ 22 | public LandSpawnTeleportEvent(@NotNull Land land, @NotNull LandPlayer landPlayer) { 23 | super(land, landPlayer); 24 | 25 | Objects.requireNonNull(landPlayer, "LandPlayer can't be null"); 26 | } 27 | 28 | @Override 29 | public @NotNull LandPlayer getLandPlayer() { 30 | assert super.getLandPlayer() != null; 31 | return super.getLandPlayer(); 32 | } 33 | 34 | public static HandlerList getHandlerList() { 35 | return handlerList; 36 | } 37 | 38 | @Override 39 | public HandlerList getHandlers() { 40 | return handlerList; 41 | } 42 | 43 | @Override 44 | public boolean isCancelled() { 45 | return cancelled; 46 | } 47 | 48 | @Override 49 | public void setCancelled(boolean cancel) { 50 | this.cancelled = cancel; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/memberholder/InboxMessageReceivedEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.memberholder; 2 | 3 | import me.angeschossen.lands.api.inbox.InboxMessage; 4 | import me.angeschossen.lands.api.memberholder.MemberHolder; 5 | import org.bukkit.event.HandlerList; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import java.util.Objects; 9 | 10 | 11 | /** 12 | * Called whenever a land or nation receives an inbox message. 13 | */ 14 | public class InboxMessageReceivedEvent extends MemberHolderEvent { 15 | public static final HandlerList handlerList = new HandlerList(); 16 | 17 | private final @NotNull InboxMessage inboxMessage; 18 | 19 | /** 20 | * Create instance of this event. 21 | * 22 | * @param memberHolder land or nation 23 | * @param inboxMessage received inbox message 24 | */ 25 | public InboxMessageReceivedEvent(@NotNull MemberHolder memberHolder, @NotNull InboxMessage inboxMessage) { 26 | super(memberHolder); 27 | 28 | Objects.requireNonNull(inboxMessage, "message can't be null"); 29 | this.inboxMessage = inboxMessage; 30 | } 31 | 32 | public static HandlerList getHandlerList() { 33 | return handlerList; 34 | } 35 | 36 | /** 37 | * Get the received message. 38 | * 39 | * @return received message 40 | */ 41 | @NotNull 42 | public InboxMessage getMessage() { 43 | return inboxMessage; 44 | } 45 | 46 | @Override 47 | public HandlerList getHandlers() { 48 | return handlerList; 49 | } 50 | } 51 | 52 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/memberholder/MemberHolderEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.memberholder; 2 | 3 | import com.github.angeschossen.pluginframework.api.utils.Checks; 4 | import com.google.common.collect.ImmutableMap; 5 | import me.angeschossen.lands.api.events.plugin.LandsEvent; 6 | import me.angeschossen.lands.api.memberholder.MemberHolder; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | import java.util.Collection; 10 | import java.util.UUID; 11 | 12 | public abstract class MemberHolderEvent extends LandsEvent { 13 | 14 | protected final @NotNull MemberHolder memberHolder; 15 | 16 | /** 17 | * Used for events that involve a land or nation. 18 | * @param memberHolder land or nation 19 | */ 20 | public MemberHolderEvent(@NotNull MemberHolder memberHolder) { 21 | Checks.requireNonNull(memberHolder, "memberHolder"); 22 | this.memberHolder = memberHolder; 23 | } 24 | 25 | /** 26 | * Get the involved land or nation. 27 | * @return land or nation 28 | */ 29 | @NotNull 30 | public MemberHolder getMemberHolder() { 31 | return memberHolder; 32 | } 33 | 34 | @Override 35 | public void setAffectedPlayers(ImmutableMap.@NotNull Builder> builder) { 36 | memberHolder.setAffectedPlayers(memberHolder.getExpressionPrefix(), builder); 37 | } 38 | 39 | @Override 40 | public void setExpressionVariables(ImmutableMap.@NotNull Builder builder) { 41 | memberHolder.setExpressionVariables(memberHolder.getExpressionPrefix(), builder,null); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/memberholder/MemberHolderLevelChangedEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.memberholder; 2 | 3 | import com.github.angeschossen.pluginframework.api.utils.Checks; 4 | import com.google.common.collect.ImmutableMap; 5 | import me.angeschossen.lands.api.levels.Level; 6 | import me.angeschossen.lands.api.memberholder.MemberHolder; 7 | import org.bukkit.event.HandlerList; 8 | import org.jetbrains.annotations.NotNull; 9 | 10 | /** 11 | * Called on level up and down of a land or nation. 12 | */ 13 | public class MemberHolderLevelChangedEvent extends MemberHolderEvent { 14 | public static final HandlerList handlerList = new HandlerList(); 15 | 16 | private final @NotNull Level previous; 17 | 18 | /** 19 | * Create instance of this event. 20 | * 21 | * @param memberHolder land or nation 22 | * @param previous the previous level 23 | */ 24 | public MemberHolderLevelChangedEvent(@NotNull MemberHolder memberHolder, @NotNull Level previous) { 25 | super(memberHolder); 26 | 27 | Checks.requireNonNull(previous, "previous level"); 28 | this.previous = previous; 29 | } 30 | 31 | public static HandlerList getHandlerList() { 32 | return handlerList; 33 | } 34 | 35 | @Override 36 | public HandlerList getHandlers() { 37 | return handlerList; 38 | } 39 | 40 | /** 41 | * Get new level. 42 | * @return new level 43 | */ 44 | @NotNull 45 | public Level getNew() { 46 | return memberHolder.getLevel(); 47 | } 48 | 49 | /** 50 | * Get the previous level. 51 | * @return previous level 52 | */ 53 | @NotNull 54 | public Level getPrevious() { 55 | return previous; 56 | } 57 | 58 | @Override 59 | public void setExpressionVariables(ImmutableMap.@NotNull Builder builder) { 60 | super.setExpressionVariables(builder); 61 | 62 | previous.setExpressionVariables("level_previous_", builder, null); 63 | memberHolder.getLevel().setExpressionVariables("level_new_", builder, null); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/memberholder/MemberHolderUpkeepEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.memberholder; 2 | 3 | import com.google.common.collect.ImmutableMap; 4 | import me.angeschossen.lands.api.memberholder.MemberHolder; 5 | import org.bukkit.event.Cancellable; 6 | import org.bukkit.event.HandlerList; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | /** 10 | * Called when a land or nation needs to pay upkeep. 11 | */ 12 | public class MemberHolderUpkeepEvent extends MemberHolderEvent implements Cancellable { 13 | public static final HandlerList handlerList = new HandlerList(); 14 | private final double upkeep; 15 | private final double balance; 16 | private boolean cancelled = false; 17 | 18 | /** 19 | * Create instance of this event. 20 | * @param memberHolder the involved memberHolder 21 | * @param upkeep upkeep to pay 22 | * @param balance the current balance 23 | */ 24 | public MemberHolderUpkeepEvent(@NotNull MemberHolder memberHolder, double upkeep, double balance) { 25 | super(memberHolder); 26 | 27 | this.upkeep = upkeep; 28 | this.balance = balance; 29 | } 30 | 31 | public static HandlerList getHandlerList() { 32 | return handlerList; 33 | } 34 | 35 | /** 36 | * Check if they have enough money to pay the upkeep. 37 | * @return true, if they don't have enough money 38 | */ 39 | public boolean IsInsufficient() { 40 | return balance < upkeep; 41 | } 42 | 43 | /** 44 | * Get the current balance. 45 | * @return current balance 46 | */ 47 | public double getBalance() { 48 | return balance; 49 | } 50 | 51 | @Override 52 | public HandlerList getHandlers() { 53 | return handlerList; 54 | } 55 | 56 | /** 57 | * Get the upkeep that they need to pay 58 | * @return upkeep to pay 59 | */ 60 | public double getUpkeep() { 61 | return upkeep; 62 | } 63 | 64 | @Override 65 | public boolean isCancelled() { 66 | return cancelled; 67 | } 68 | 69 | @Override 70 | public void setCancelled(boolean cancelled) { 71 | this.cancelled = cancelled; 72 | } 73 | 74 | @Override 75 | public void setExpressionVariables(ImmutableMap.@NotNull Builder builder) { 76 | super.setExpressionVariables(builder); 77 | 78 | builder.put("upkeep", upkeep) 79 | .put(memberHolder.getExpressionPrefix() + "_balance", balance); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/nation/edit/NationCreateEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.nation.edit; 2 | 3 | import me.angeschossen.lands.api.nation.Nation; 4 | import me.angeschossen.lands.api.player.LandPlayer; 5 | import org.bukkit.event.Cancellable; 6 | import org.bukkit.event.HandlerList; 7 | import org.jetbrains.annotations.NotNull; 8 | import org.jetbrains.annotations.Nullable; 9 | 10 | import java.util.UUID; 11 | 12 | /** 13 | * Called whenever a player tries to create a nation. 14 | */ 15 | public class NationCreateEvent extends NationEditEvent implements Cancellable { 16 | 17 | public static HandlerList handlerList = new HandlerList(); 18 | private boolean cancelled; 19 | 20 | /** 21 | * Create an instance of this event. 22 | * 23 | * @param landPlayer null, if no player involved in creating this nation 24 | * @param nation the nation being created 25 | */ 26 | public NationCreateEvent(@Nullable LandPlayer landPlayer, @NotNull Nation nation) { 27 | super(nation, landPlayer); 28 | } 29 | 30 | /** 31 | * Create an instance of this event. 32 | * 33 | * @param playerUUID null, if no player involved in creating this nation 34 | * @param nation the nation being created 35 | */ 36 | public NationCreateEvent(@Nullable UUID playerUUID, @NotNull Nation nation) { 37 | super(nation, playerUUID); 38 | } 39 | 40 | public static HandlerList getHandlerList() { 41 | return handlerList; 42 | } 43 | 44 | @Override 45 | public HandlerList getHandlers() { 46 | return handlerList; 47 | } 48 | 49 | @Override 50 | public boolean isCancelled() { 51 | return this.cancelled; 52 | } 53 | 54 | @Override 55 | public void setCancelled(boolean cancelled) { 56 | this.cancelled = cancelled; 57 | } 58 | 59 | @Override 60 | public @Nullable String getLogInfo() { 61 | return toString(); 62 | } 63 | 64 | @Override 65 | public String toString() { 66 | return "NationCreateEvent{" + 67 | "nation=" + nation.toString() + 68 | "}"; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/nation/edit/NationEditEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.nation.edit; 2 | 3 | import com.github.angeschossen.pluginframework.api.utils.Checks; 4 | import com.google.common.collect.ImmutableMap; 5 | import me.angeschossen.lands.api.events.player.PlayerNullableEvent; 6 | import me.angeschossen.lands.api.nation.Nation; 7 | import me.angeschossen.lands.api.player.LandPlayer; 8 | import org.jetbrains.annotations.NotNull; 9 | import org.jetbrains.annotations.Nullable; 10 | 11 | import java.util.Collection; 12 | import java.util.UUID; 13 | 14 | /** 15 | * Used for events that modify a nation. 16 | */ 17 | public abstract class NationEditEvent extends PlayerNullableEvent { 18 | 19 | 20 | protected final @NotNull Nation nation; 21 | 22 | /** 23 | * Create an instance of this event. 24 | * 25 | * @param nation nation to be edited 26 | * @param landPlayer involved player 27 | */ 28 | public NationEditEvent(@NotNull Nation nation, @Nullable LandPlayer landPlayer) { 29 | super(landPlayer); 30 | 31 | Checks.requireNonNull(nation, "nation"); 32 | this.nation = nation; 33 | } 34 | 35 | /** 36 | * Create an instance of this event. 37 | * 38 | * @param nation nation to be edited 39 | * @param landPlayer involved player 40 | */ 41 | public NationEditEvent(@NotNull Nation nation, @Nullable UUID landPlayer) { 42 | super(landPlayer); 43 | 44 | Checks.requireNonNull(nation, "nation"); 45 | this.nation = nation; 46 | } 47 | 48 | /** 49 | * Get the nation that is affected by this event. 50 | * @return never null 51 | */ 52 | @NotNull 53 | public Nation getNation() { 54 | return nation; 55 | } 56 | 57 | @Override 58 | public void setAffectedPlayers(ImmutableMap.@NotNull Builder> builder) { 59 | super.setAffectedPlayers(builder); 60 | 61 | nation.setAffectedPlayers("nation_", builder); 62 | } 63 | 64 | @Override 65 | public void setExpressionVariables(ImmutableMap.@NotNull Builder builder) { 66 | super.setExpressionVariables(builder); 67 | 68 | nation.setExpressionVariables("nation_", builder, getPlayerUID()); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/nation/edit/NationRenameEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.nation.edit; 2 | 3 | import com.github.angeschossen.pluginframework.api.utils.Checks; 4 | import com.google.common.collect.ImmutableMap; 5 | import me.angeschossen.lands.api.nation.Nation; 6 | import me.angeschossen.lands.api.player.LandPlayer; 7 | import org.bukkit.event.Cancellable; 8 | import org.bukkit.event.HandlerList; 9 | import org.jetbrains.annotations.NotNull; 10 | 11 | /** 12 | * Called when a nation is being renamed. 13 | */ 14 | public class NationRenameEvent extends NationEditEvent implements Cancellable { 15 | public static final HandlerList handlerList = new HandlerList(); 16 | private final @NotNull String oldName; 17 | private final @NotNull String newName; 18 | private boolean cancelled = false; 19 | 20 | /** 21 | * Create an instance of this event. 22 | * 23 | * @param nation nation that is being renamed 24 | * @param oldName old name 25 | * @param newName new name to set 26 | * @param landPlayer The player that is renaming the nation. If null, a player didn't initiate setting a new name. 27 | */ 28 | public NationRenameEvent(@NotNull Nation nation, @NotNull String oldName, @NotNull String newName, LandPlayer landPlayer) { 29 | super(nation, landPlayer); 30 | 31 | Checks.requireNonNull(oldName, "oldName"); 32 | Checks.requireNonNull(newName, "newName"); 33 | this.oldName = oldName; 34 | this.newName = newName; 35 | } 36 | 37 | public static HandlerList getHandlerList() { 38 | return handlerList; 39 | } 40 | 41 | /** 42 | * Get the current name. 43 | * @return current name including color codes etc. 44 | */ 45 | @NotNull 46 | public String getCurrentName() { 47 | return oldName; 48 | } 49 | 50 | @Override 51 | public HandlerList getHandlers() { 52 | return handlerList; 53 | } 54 | 55 | /** 56 | * Get the new name. 57 | * @return new name including color codes etc. 58 | */ 59 | @NotNull 60 | public String getNewName() { 61 | return newName; 62 | } 63 | 64 | @Override 65 | public boolean isCancelled() { 66 | return cancelled; 67 | } 68 | 69 | @Override 70 | public void setCancelled(boolean cancelled) { 71 | this.cancelled = cancelled; 72 | } 73 | 74 | @Override 75 | public void setExpressionVariables(ImmutableMap.@NotNull Builder builder) { 76 | super.setExpressionVariables(builder); 77 | 78 | builder.put("name_old", oldName) 79 | .put("name_new", newName); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/nation/member/NationEditMemberCancellableEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.nation.member; 2 | 3 | import me.angeschossen.lands.api.land.Land; 4 | import me.angeschossen.lands.api.nation.Nation; 5 | import org.bukkit.event.Cancellable; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import java.util.UUID; 9 | 10 | /** 11 | * Called whenever a nation modifies one of its members (lands) and the event is cancellable. 12 | */ 13 | public abstract class NationEditMemberCancellableEvent extends NationEditMemberEvent implements Cancellable { 14 | 15 | protected boolean cancelled; 16 | 17 | public NationEditMemberCancellableEvent(@NotNull Nation nation,@NotNull Land land, UUID initiator) { 18 | super(nation, land, initiator); 19 | } 20 | 21 | @Override 22 | public boolean isCancelled() { 23 | return this.cancelled; 24 | } 25 | 26 | @Override 27 | public void setCancelled(boolean cancelled) { 28 | this.cancelled = cancelled; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/nation/member/NationEditMemberEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.nation.member; 2 | 3 | import com.github.angeschossen.pluginframework.api.utils.Checks; 4 | import com.google.common.collect.ImmutableMap; 5 | import me.angeschossen.lands.api.events.land.LandEvent; 6 | import me.angeschossen.lands.api.land.Land; 7 | import me.angeschossen.lands.api.nation.Nation; 8 | import org.jetbrains.annotations.NotNull; 9 | import org.jetbrains.annotations.Nullable; 10 | 11 | import java.util.Collection; 12 | import java.util.UUID; 13 | 14 | /** 15 | * Called whenever a nation modifies one of its members (lands). 16 | */ 17 | public abstract class NationEditMemberEvent extends LandEvent { 18 | protected final @Nullable UUID initiator; 19 | protected final @NotNull Nation nation; 20 | protected final @NotNull Land land; 21 | 22 | /** 23 | * Used for events that involve a nation modifying one of its lands. 24 | * 25 | * @param nation the nation 26 | * @param land the modified land 27 | * @param initiator the initiatior of this action 28 | */ 29 | public NationEditMemberEvent(@NotNull Nation nation, @NotNull Land land, @Nullable UUID initiator) { 30 | super(land, initiator); 31 | 32 | Checks.requireNonNull(nation, "nation"); 33 | Checks.requireNonNull(land, "land"); 34 | this.initiator = initiator; 35 | this.land = land; 36 | this.nation = nation; 37 | } 38 | 39 | /** 40 | * Get the involved nation. 41 | * @return never null 42 | */ 43 | @NotNull 44 | public Nation getNation() { 45 | return nation; 46 | } 47 | 48 | @Override 49 | public void setAffectedPlayers(ImmutableMap.@NotNull Builder> builder) { 50 | super.setAffectedPlayers(builder); 51 | 52 | nation.setAffectedPlayers("nation_", builder); 53 | land.setAffectedPlayers("land_", builder); 54 | } 55 | 56 | @Override 57 | public void setExpressionVariables(ImmutableMap.@NotNull Builder builder) { 58 | super.setExpressionVariables(builder); 59 | 60 | UUID uuid = getPlayerUID(); 61 | nation.setExpressionVariables("nation_", builder, uuid); 62 | land.setExpressionVariables("land_", builder, uuid); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/nation/member/NationTrustLandEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.nation.member; 2 | 3 | import me.angeschossen.lands.api.land.Land; 4 | import me.angeschossen.lands.api.nation.Nation; 5 | import org.bukkit.event.HandlerList; 6 | import org.jetbrains.annotations.NotNull; 7 | import org.jetbrains.annotations.Nullable; 8 | 9 | import java.util.UUID; 10 | 11 | /** 12 | * Called when a land joins a nation. 13 | * Usually at "/nations accept" 14 | */ 15 | public class NationTrustLandEvent extends NationEditMemberCancellableEvent { 16 | 17 | public static HandlerList handlerList = new HandlerList(); 18 | 19 | /** 20 | * Create an instance of this event. 21 | * 22 | * @param nation nation that previously invited the land 23 | * @param land land that accepts the nation's invitation to join them 24 | * @param initiator the player that initially sent the invitation to the land 25 | */ 26 | public NationTrustLandEvent(@NotNull Nation nation, @NotNull Land land, @Nullable UUID initiator) { 27 | super(nation, land, initiator); 28 | } 29 | 30 | public static HandlerList getHandlerList() { 31 | return handlerList; 32 | } 33 | 34 | @Override 35 | public @NotNull 36 | HandlerList getHandlers() { 37 | return handlerList; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/nation/member/NationUntrustLandEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.nation.member; 2 | 3 | import com.github.angeschossen.pluginframework.api.utils.Checks; 4 | import me.angeschossen.lands.api.land.Land; 5 | import me.angeschossen.lands.api.nation.Nation; 6 | import org.bukkit.event.HandlerList; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | import java.util.UUID; 10 | 11 | /** 12 | * Called whenever a nation removes a land. 13 | */ 14 | public class NationUntrustLandEvent extends NationEditMemberCancellableEvent { 15 | 16 | public static HandlerList handlerList = new HandlerList(); 17 | private final @NotNull UntrustReason reason; 18 | 19 | /** 20 | * Create an instance of this event. 21 | * 22 | * @param nation the nation that removes the land 23 | * @param land the land 24 | * @param initiator player that initiated the removal. Usually by executing "/nations untrust" 25 | * @param reason the reason of removal 26 | */ 27 | public NationUntrustLandEvent(@NotNull Nation nation, @NotNull Land land, UUID initiator, @NotNull UntrustReason reason) { 28 | super(nation, land, initiator); 29 | 30 | Checks.requireNonNull(reason, "reason"); 31 | this.reason = reason; 32 | } 33 | 34 | public static HandlerList getHandlerList() { 35 | return handlerList; 36 | } 37 | 38 | /** 39 | * Get the reason of removal. 40 | * 41 | * @return reason of removal 42 | */ 43 | @NotNull 44 | public UntrustReason getReason() { 45 | return reason; 46 | } 47 | 48 | @Override 49 | public @NotNull 50 | HandlerList getHandlers() { 51 | return handlerList; 52 | } 53 | 54 | public enum UntrustReason { 55 | /** 56 | * Used when executing "/nations untrust" 57 | */ 58 | COMMAND, 59 | /** 60 | * Used when a land is automatically being untrusted, because they failed to pay the taxes to the nation. 61 | */ 62 | TAXES 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/player/PlayerEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.player; 2 | 3 | import me.angeschossen.lands.api.player.LandPlayer; 4 | import org.jetbrains.annotations.NotNull; 5 | import org.jetbrains.annotations.Nullable; 6 | 7 | import java.util.Objects; 8 | import java.util.UUID; 9 | 10 | /** 11 | * Used for events that affect a player. 12 | */ 13 | public abstract class PlayerEvent extends PlayerNullableEvent { 14 | 15 | /** 16 | * Constructor 17 | * 18 | * @param landPlayer the player that is online 19 | */ 20 | public PlayerEvent(@NotNull LandPlayer landPlayer) { 21 | super(landPlayer); 22 | 23 | Objects.requireNonNull(landPlayer, "LandPlayer can't be null"); 24 | } 25 | 26 | /** 27 | * Constructor 28 | * 29 | * @param playerUUID UUID of the player, that might be offline 30 | */ 31 | public PlayerEvent(@NotNull UUID playerUUID) { 32 | super(playerUUID); 33 | 34 | Objects.requireNonNull(playerUUID, "UUID can't be null"); 35 | } 36 | 37 | /** 38 | * Get the player that is online 39 | * 40 | * @return might be null, if player not online 41 | */ 42 | @Override 43 | @Nullable 44 | public LandPlayer getLandPlayer() { 45 | return landPlayer; 46 | } 47 | 48 | /** 49 | * Get the player's UUID 50 | * 51 | * @return never null 52 | */ 53 | @Override 54 | @NotNull 55 | public UUID getPlayerUUID() { 56 | return Objects.requireNonNull(super.getPlayerUUID(), "expected player UUID"); 57 | } 58 | 59 | /** 60 | * Get the player's UUID 61 | * 62 | * @return never null 63 | * @deprecated Use {{@link #getPlayerUUID()}} instead. 64 | */ 65 | @Override 66 | @NotNull 67 | public UUID getPlayerUID() { 68 | return getPlayerUUID(); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/player/PlayerLandEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.player; 2 | 3 | import com.github.angeschossen.pluginframework.api.utils.Checks; 4 | import com.google.common.collect.ImmutableMap; 5 | import me.angeschossen.lands.api.land.Area; 6 | import me.angeschossen.lands.api.land.Land; 7 | import me.angeschossen.lands.api.player.LandPlayer; 8 | import org.bukkit.event.Cancellable; 9 | import org.jetbrains.annotations.NotNull; 10 | import org.jetbrains.annotations.Nullable; 11 | 12 | import java.util.Collection; 13 | import java.util.UUID; 14 | 15 | /** 16 | * Used for events that affect a player and land. 17 | */ 18 | public abstract class PlayerLandEvent extends PlayerEvent implements Cancellable { 19 | private final @Nullable Area area; 20 | private final @NotNull Land land; 21 | private boolean cancelled; 22 | 23 | /** 24 | * Constructor 25 | * 26 | * @param land the affected land 27 | * @param area the affected area 28 | * @param landPlayer involved player 29 | */ 30 | public PlayerLandEvent(@NotNull Land land, @Nullable Area area, @NotNull LandPlayer landPlayer) { 31 | super(landPlayer); 32 | 33 | Checks.requireNonNull(land, "land"); 34 | Checks.requireNonNull(landPlayer, "landPlayer"); 35 | this.land = land; 36 | this.area = area; 37 | this.landPlayer = landPlayer; 38 | } 39 | 40 | /** 41 | * Get the area. 42 | * @return if null, this event affects the whole land. If not null, this event only affects this area. 43 | */ 44 | @Nullable 45 | public Area getArea() { 46 | return area; 47 | } 48 | 49 | /** 50 | * Get the land. 51 | * @see #getArea() 52 | * @return never null 53 | */ 54 | @NotNull 55 | public Land getLand() { 56 | return land; 57 | } 58 | 59 | @Override 60 | public boolean isCancelled() { 61 | return cancelled; 62 | } 63 | 64 | @Override 65 | public void setCancelled(boolean b) { 66 | this.cancelled = b; 67 | } 68 | 69 | @Override 70 | public void setAffectedPlayers(ImmutableMap.@NotNull Builder> builder) { 71 | super.setAffectedPlayers(builder); 72 | land.setAffectedPlayers("land_", builder); 73 | } 74 | 75 | @Override 76 | public void setExpressionVariables(ImmutableMap.@NotNull Builder builder) { 77 | super.setExpressionVariables(builder); 78 | 79 | UUID uuid = getPlayerUID(); 80 | if (area != null) { 81 | area.setExpressionVariables("area_", builder, uuid); 82 | } else { 83 | land.setExpressionVariables("land_", builder, uuid); 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/player/area/PlayerAreaEnterEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.player.area; 2 | 3 | import me.angeschossen.lands.api.land.Area; 4 | import me.angeschossen.lands.api.player.LandPlayer; 5 | import org.bukkit.event.Cancellable; 6 | import org.jetbrains.annotations.Nullable; 7 | 8 | /** 9 | * This event is called when a player enters a area. 10 | * Please note that the player must not enter from wilderness. 11 | * They can also enter from a different area of the same or a different land. 12 | */ 13 | public class PlayerAreaEnterEvent extends PlayerAreaEvent implements Cancellable { 14 | private final Area from; 15 | private boolean cancelled; 16 | 17 | public PlayerAreaEnterEvent(@Nullable Area from, Area area, LandPlayer landPlayer) { 18 | super(area, landPlayer); 19 | 20 | this.from = from; 21 | } 22 | 23 | 24 | /** 25 | * Get the area from which the player is entering from. 26 | * This area can be from the same or from a different land as {@link #getArea} 27 | * 28 | * @return This method will return null if the player is entering from the wilderness. 29 | */ 30 | @Nullable 31 | public Area getFrom() { 32 | return from; 33 | } 34 | 35 | @Override 36 | public boolean isCancelled() { 37 | return cancelled; 38 | } 39 | 40 | @Override 41 | public void setCancelled(boolean b) { 42 | this.cancelled = b; 43 | } 44 | 45 | @Override 46 | public String toString() { 47 | return "PlayerAreaEnterEvent{player=" + landPlayer.getPlayer() + "}"; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/player/area/PlayerAreaEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.player.area; 2 | 3 | import com.google.common.collect.ImmutableMap; 4 | import me.angeschossen.lands.api.events.player.PlayerEvent; 5 | import me.angeschossen.lands.api.land.Area; 6 | import me.angeschossen.lands.api.player.LandPlayer; 7 | import org.bukkit.event.HandlerList; 8 | import org.jetbrains.annotations.NotNull; 9 | 10 | import java.util.Collection; 11 | import java.util.UUID; 12 | 13 | /** 14 | * Used for events where a player interacts with an area. 15 | */ 16 | public abstract class PlayerAreaEvent extends PlayerEvent { 17 | public static HandlerList handlerList = new HandlerList(); 18 | protected final Area area; 19 | 20 | public PlayerAreaEvent(@NotNull Area area, LandPlayer landPlayer) { 21 | super(landPlayer); 22 | 23 | this.area = area; 24 | } 25 | 26 | public PlayerAreaEvent(@NotNull Area area, UUID player) { 27 | super(player); 28 | 29 | this.area = area; 30 | } 31 | 32 | public static HandlerList getHandlerList() { 33 | return handlerList; 34 | } 35 | 36 | /** 37 | * Get the area. Can be entering or leaving, depending on the event. 38 | * 39 | * @return the affected area 40 | */ 41 | @NotNull 42 | public Area getArea() { 43 | return area; 44 | } 45 | 46 | @Override 47 | public @NotNull HandlerList getHandlers() { 48 | return handlerList; 49 | } 50 | 51 | @Override 52 | public void setAffectedPlayers(ImmutableMap.@NotNull Builder> builder) { 53 | super.setAffectedPlayers(builder); 54 | 55 | area.setAffectedPlayers("area_", builder); 56 | } 57 | 58 | @Override 59 | public void setExpressionVariables(ImmutableMap.@NotNull Builder builder) { 60 | super.setExpressionVariables(builder); 61 | 62 | area.setExpressionVariables("area_", builder, getPlayerUID()); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/player/area/PlayerAreaLeaveEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.player.area; 2 | 3 | import me.angeschossen.lands.api.land.Area; 4 | import me.angeschossen.lands.api.player.LandPlayer; 5 | import org.bukkit.event.Cancellable; 6 | 7 | /** 8 | * This event is called when a player leaves a area into wilderness. 9 | */ 10 | public class PlayerAreaLeaveEvent extends PlayerAreaEvent implements Cancellable { 11 | private boolean cancelled; 12 | 13 | public PlayerAreaLeaveEvent(Area area, LandPlayer landPlayer) { 14 | super(area, landPlayer); 15 | } 16 | 17 | @Override 18 | public boolean isCancelled() { 19 | return cancelled; 20 | } 21 | 22 | @Override 23 | public void setCancelled(boolean b) { 24 | this.cancelled = b; 25 | } 26 | 27 | @Override 28 | public String toString() { 29 | return "PlayerAreaLeaveEvent{player=" + landPlayer.getPlayer() + "}"; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/player/database/PlayerDataLoadedEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.player.database; 2 | 3 | import me.angeschossen.lands.api.events.player.PlayerEvent; 4 | import me.angeschossen.lands.api.player.LandPlayer; 5 | import org.bukkit.event.HandlerList; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import java.util.Objects; 9 | 10 | /** 11 | * Called once the player data of a player that just joined, is fully loaded. 12 | */ 13 | public class PlayerDataLoadedEvent extends PlayerEvent { 14 | public static final HandlerList handlerList = new HandlerList(); 15 | 16 | /** 17 | * Create instance 18 | * 19 | * @param landPlayer the joined player 20 | */ 21 | public PlayerDataLoadedEvent(@NotNull LandPlayer landPlayer) { 22 | super(landPlayer); 23 | } 24 | 25 | /** 26 | * Get the joined player. 27 | * 28 | * @return never null 29 | */ 30 | @Override 31 | public @NotNull LandPlayer getLandPlayer() { 32 | return Objects.requireNonNull(super.getLandPlayer(), "expected landPlayer"); 33 | } 34 | 35 | @NotNull 36 | @Override 37 | public HandlerList getHandlers() { 38 | return handlerList; 39 | } 40 | 41 | public static HandlerList getHandlerList() { 42 | return handlerList; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/player/role/PlayerToggleRoleFlagEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.player.role; 2 | 3 | import com.github.angeschossen.pluginframework.api.utils.Checks; 4 | import com.google.common.collect.ImmutableMap; 5 | import me.angeschossen.lands.api.events.role.RoleEvent; 6 | import me.angeschossen.lands.api.flags.type.RoleFlag; 7 | import me.angeschossen.lands.api.player.LandPlayer; 8 | import me.angeschossen.lands.api.role.Role; 9 | import org.bukkit.event.Cancellable; 10 | import org.bukkit.event.HandlerList; 11 | import org.jetbrains.annotations.NotNull; 12 | 13 | import java.util.Collection; 14 | import java.util.UUID; 15 | 16 | /** 17 | * Called whenever a player toggles a role flag. 18 | */ 19 | public class PlayerToggleRoleFlagEvent extends RoleEvent implements Cancellable { 20 | public static final HandlerList handlerList = new HandlerList(); 21 | private final @NotNull LandPlayer landPlayer; 22 | private final @NotNull RoleFlag roleFlag; 23 | private boolean cancelled; 24 | 25 | /** 26 | * Create instance of this event. 27 | * 28 | * @param role role for which the flag is changed 29 | * @param landPlayer the player that changes the state 30 | */ 31 | public PlayerToggleRoleFlagEvent(@NotNull Role role, @NotNull RoleFlag roleFlag, @NotNull LandPlayer landPlayer) { 32 | super(role); 33 | 34 | this.roleFlag = Checks.requireNonNull(roleFlag, "roleFlag"); 35 | this.landPlayer = Checks.requireNonNull(landPlayer, "landPlayer"); 36 | } 37 | 38 | public @NotNull RoleFlag getFlag() { 39 | return roleFlag; 40 | } 41 | 42 | /** 43 | * Get the player. 44 | * 45 | * @return player that toggles the flag 46 | */ 47 | public @NotNull LandPlayer getLandPlayer() { 48 | return landPlayer; 49 | } 50 | 51 | @Override 52 | public @NotNull HandlerList getHandlers() { 53 | return handlerList; 54 | } 55 | 56 | public static HandlerList getHandlerList() { 57 | return handlerList; 58 | } 59 | 60 | @Override 61 | public boolean isCancelled() { 62 | return cancelled; 63 | } 64 | 65 | @Override 66 | public void setCancelled(boolean b) { 67 | this.cancelled = b; 68 | } 69 | 70 | @Override 71 | public void setAffectedPlayers(ImmutableMap.@NotNull Builder> builder) { 72 | landPlayer.setAffectedPlayers("player_", builder); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/player/teleportation/PlayerRandomTeleportEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.player.teleportation; 2 | 3 | import com.google.common.collect.ImmutableMap; 4 | import me.angeschossen.lands.api.events.player.PlayerEvent; 5 | import me.angeschossen.lands.api.player.LandPlayer; 6 | import org.bukkit.Location; 7 | import org.bukkit.event.Cancellable; 8 | import org.bukkit.event.HandlerList; 9 | import org.jetbrains.annotations.NotNull; 10 | 11 | /** 12 | * Called whenever a player randomly teleports either using "/lands wild" or 13 | * initiated by a 3rd party plugin. 14 | */ 15 | public class PlayerRandomTeleportEvent extends PlayerEvent implements Cancellable { 16 | public static final HandlerList handlerList = new HandlerList(); 17 | private final @NotNull Location destination; 18 | private boolean cancelled = false; 19 | 20 | /** 21 | * Create instance of this event. 22 | * @param landPlayer player that randomly teleports 23 | * @param location the random destination 24 | */ 25 | public PlayerRandomTeleportEvent(@NotNull LandPlayer landPlayer, @NotNull Location location) { 26 | super(landPlayer); 27 | 28 | this.destination = location; 29 | } 30 | 31 | public static HandlerList getHandlerList() { 32 | return handlerList; 33 | } 34 | 35 | /** 36 | * Get the random destination. 37 | * @return random destination 38 | */ 39 | @NotNull 40 | public Location getDestination() { 41 | return destination; 42 | } 43 | 44 | @Override 45 | public HandlerList getHandlers() { 46 | return handlerList; 47 | } 48 | 49 | @Override 50 | public boolean isCancelled() { 51 | return cancelled; 52 | } 53 | 54 | @Override 55 | public void setCancelled(boolean cancelled) { 56 | this.cancelled = cancelled; 57 | } 58 | 59 | @Override 60 | public void setExpressionVariables(ImmutableMap.@NotNull Builder builder) { 61 | super.setExpressionVariables(builder); 62 | 63 | builder.put("destination_world", destination.getWorld().getName()) 64 | .put("destination_x", destination.getBlockX()) 65 | .put("destination_y", destination.getBlockY()) 66 | .put("destination_z", destination.getBlockZ()); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/player/teleportation/PlayerSpawnLandEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.player.teleportation; 2 | 3 | import com.google.common.collect.ImmutableMap; 4 | import me.angeschossen.lands.api.events.land.spawn.LandSpawnTeleportEvent; 5 | import me.angeschossen.lands.api.events.player.PlayerEvent; 6 | import me.angeschossen.lands.api.land.Land; 7 | import me.angeschossen.lands.api.player.LandPlayer; 8 | import org.bukkit.event.Cancellable; 9 | import org.bukkit.event.HandlerList; 10 | import org.jetbrains.annotations.NotNull; 11 | 12 | import java.util.Collection; 13 | import java.util.UUID; 14 | 15 | /** 16 | * Deprecated. Use {@link LandSpawnTeleportEvent} instead. 17 | */ 18 | @Deprecated 19 | public class PlayerSpawnLandEvent extends PlayerEvent implements Cancellable { 20 | public static final HandlerList handlerList = new HandlerList(); 21 | private final @NotNull Land land; 22 | private boolean cancelled = false; 23 | 24 | public PlayerSpawnLandEvent(@NotNull Land land, LandPlayer landPlayer) { 25 | super(landPlayer); 26 | 27 | this.land = land; 28 | } 29 | 30 | public static HandlerList getHandlerList() { 31 | return handlerList; 32 | } 33 | 34 | @Override 35 | public void setAffectedPlayers(ImmutableMap.@NotNull Builder> builder) { 36 | super.setAffectedPlayers(builder); 37 | 38 | land.setAffectedPlayers("land_",builder); 39 | } 40 | 41 | @Override 42 | public void setExpressionVariables(ImmutableMap.@NotNull Builder builder) { 43 | super.setExpressionVariables(builder); 44 | 45 | land.setExpressionVariables("land_", builder,getPlayerUID()); 46 | } 47 | 48 | @Override 49 | public @NotNull HandlerList getHandlers() { 50 | return handlerList; 51 | } 52 | 53 | @NotNull 54 | public Land getLand() { 55 | return land; 56 | } 57 | 58 | @Override 59 | public boolean isCancelled() { 60 | return cancelled; 61 | } 62 | 63 | @Override 64 | public void setCancelled(boolean cancelled) { 65 | this.cancelled = cancelled; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/plugin/LandsEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.plugin; 2 | 3 | 4 | import com.github.angeschossen.pluginframework.api.events.PluginEvent; 5 | 6 | /** 7 | * Used for all events of Lands. 8 | */ 9 | public abstract class LandsEvent extends PluginEvent { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/plugin/TargetableEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.plugin; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import java.util.UUID; 6 | 7 | /** 8 | * Used for events that affect a target. 9 | */ 10 | public interface TargetableEvent { 11 | 12 | /** 13 | * Use {@link #getTargetUUID()} instead. 14 | * @return The target 15 | */ 16 | @Deprecated 17 | @NotNull UUID getTargetUID(); 18 | 19 | /** 20 | * Get the provided target player. Used at trusting players etc. 21 | * @return The target 22 | */ 23 | @NotNull UUID getTargetUUID(); 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/rent/PlayerRentalEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.rent; 2 | 3 | import me.angeschossen.lands.api.land.Area; 4 | import me.angeschossen.lands.api.player.LandPlayer; 5 | import org.jetbrains.annotations.NotNull; 6 | 7 | /** 8 | * Called whenever a player rents or buys an area or complete land. 9 | * Whole lands can only be sold and not rented. 10 | */ 11 | public class PlayerRentalEvent extends RentalEvent { 12 | 13 | /** 14 | * Create insteace. 15 | * @param area the area to be rented or sold 16 | * @param landPlayer the player that rents or purchases the area or land. Whole lands can only be sold. 17 | */ 18 | public PlayerRentalEvent(@NotNull Area area, @NotNull LandPlayer landPlayer) { 19 | super(area, landPlayer); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/rent/RentalEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.rent; 2 | 3 | import com.github.angeschossen.pluginframework.api.utils.Checks; 4 | import me.angeschossen.lands.api.events.player.area.PlayerAreaEvent; 5 | import me.angeschossen.lands.api.land.Area; 6 | import me.angeschossen.lands.api.land.rental.offer.base.RentalOfferBase; 7 | import me.angeschossen.lands.api.player.LandPlayer; 8 | import org.bukkit.event.Cancellable; 9 | import org.jetbrains.annotations.NotNull; 10 | 11 | import java.util.Objects; 12 | import java.util.UUID; 13 | 14 | /** 15 | * Called for events related to rental. 16 | */ 17 | public abstract class RentalEvent extends PlayerAreaEvent implements Cancellable { 18 | private boolean cancelled; 19 | 20 | /** 21 | * Create instance. 22 | * 23 | * @param area rented or sold area 24 | * @param playerUUID involved player 25 | */ 26 | public RentalEvent(@NotNull Area area, @NotNull UUID playerUUID) { 27 | super(Checks.requireNonNull(area, "area"), Checks.requireNonNull(playerUUID, "playerUUID")); 28 | } 29 | 30 | /** 31 | * Create instance. 32 | * 33 | * @param area rented or sold area 34 | * @param landPlayer involved player 35 | */ 36 | public RentalEvent(@NotNull Area area, @NotNull LandPlayer landPlayer) { 37 | super(Checks.requireNonNull(area, "area"), Checks.requireNonNull(landPlayer, "landPlayer")); 38 | } 39 | 40 | /** 41 | * Get the rental offer. 42 | * 43 | * @return never null 44 | */ 45 | @NotNull 46 | public RentalOfferBase getOffer() { 47 | return Objects.requireNonNull(area.getRentalOffer(), "expected rental offer"); 48 | } 49 | 50 | /** 51 | * Get the area. 52 | * 53 | * @return if this is the default area, the whole land is being sold. 54 | */ 55 | @Override 56 | public @NotNull Area getArea() { 57 | return super.getArea(); 58 | } 59 | 60 | @Override 61 | public boolean isCancelled() { 62 | return cancelled; 63 | } 64 | 65 | @Override 66 | public void setCancelled(boolean cancel) { 67 | this.cancelled = cancel; 68 | } 69 | } -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/rent/RentalExpireEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.rent; 2 | 3 | import com.github.angeschossen.pluginframework.api.utils.Checks; 4 | import me.angeschossen.lands.api.land.Area; 5 | import org.jetbrains.annotations.NotNull; 6 | 7 | import java.util.Objects; 8 | 9 | /** 10 | * Called whenever a rental or sold area expires. Sold areas expire when the tenant is forcefully removed and not by time. 11 | */ 12 | public class RentalExpireEvent extends RentalEvent { 13 | /** 14 | * Create instance. 15 | * 16 | * @param area the sold or rented area 17 | */ 18 | public RentalExpireEvent(@NotNull Area area) { 19 | super(Checks.requireNonNull(area, "area"), Objects.requireNonNull(area.getTenant(), "can only call this event for rented areas")); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/rent/RentalOfferCreateEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.rent; 2 | 3 | import com.github.angeschossen.pluginframework.api.utils.Checks; 4 | import me.angeschossen.lands.api.land.Area; 5 | import me.angeschossen.lands.api.land.rental.offer.base.RentalOfferBase; 6 | import me.angeschossen.lands.api.player.LandPlayer; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | /** 10 | * Called whenever a rent or sell offer is created. 11 | */ 12 | public class RentalOfferCreateEvent extends RentalEvent { 13 | private final RentalOfferBase rentalOffer; 14 | 15 | /** 16 | * Create instance. 17 | * 18 | * @param area the area to be rented or sold. If area is the default area, the complete land will be sold. 19 | * @param landPlayer the player that creates the offer 20 | * @param rentalOffer the created offer 21 | */ 22 | public RentalOfferCreateEvent(@NotNull Area area, @NotNull LandPlayer landPlayer, @NotNull RentalOfferBase rentalOffer) { 23 | super(area, landPlayer); 24 | 25 | this.rentalOffer = Checks.requireNonNull(rentalOffer, "rentalOffer"); 26 | } 27 | 28 | /** 29 | * Get the created offer. 30 | * 31 | * @return never null 32 | */ 33 | @Override 34 | public @NotNull RentalOfferBase getOffer() { 35 | return rentalOffer; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/role/RoleEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.role; 2 | 3 | import com.github.angeschossen.pluginframework.api.utils.Checks; 4 | import com.google.common.collect.ImmutableMap; 5 | import me.angeschossen.lands.api.events.plugin.LandsEvent; 6 | import me.angeschossen.lands.api.role.Role; 7 | import org.bukkit.event.HandlerList; 8 | import org.jetbrains.annotations.NotNull; 9 | 10 | import java.util.Collection; 11 | import java.util.UUID; 12 | 13 | public abstract class RoleEvent extends LandsEvent { 14 | protected final @NotNull Role role; 15 | 16 | protected RoleEvent(@NotNull Role role) { 17 | this.role = Checks.requireNonNull(role, "role"); 18 | } 19 | 20 | /** 21 | * Get the role. 22 | * 23 | * @return role affected by this event 24 | */ 25 | public @NotNull Role getRole() { 26 | return role; 27 | } 28 | 29 | @Override 30 | public void setExpressionVariables(ImmutableMap.@NotNull Builder builder) { 31 | role.setExpressionVariables("role_", builder, null); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/war/WarEndEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.war; 2 | 3 | import me.angeschossen.lands.api.memberholder.MemberHolder; 4 | import me.angeschossen.lands.api.war.War; 5 | import me.angeschossen.lands.api.war.enums.WarResult; 6 | import org.bukkit.event.HandlerList; 7 | import org.jetbrains.annotations.NotNull; 8 | import org.jetbrains.annotations.Nullable; 9 | 10 | /** 11 | * Called when a war ends. 12 | */ 13 | public class WarEndEvent extends WarEvent { 14 | public static HandlerList handlerList = new HandlerList(); 15 | private final @NotNull WarResult warResult; 16 | private final @Nullable MemberHolder winner; 17 | 18 | /** 19 | * Create an instance of this event. 20 | * @param war war that ended 21 | * @param warResult result of the war 22 | * @param winner if null, no winner 23 | */ 24 | public WarEndEvent(@NotNull War war, @NotNull WarResult warResult, @Nullable MemberHolder winner) { 25 | super(war); 26 | 27 | this.warResult = warResult; 28 | this.winner = winner; 29 | } 30 | 31 | public static HandlerList getHandlerList() { 32 | return handlerList; 33 | } 34 | 35 | @Override 36 | public @NotNull HandlerList getHandlers() { 37 | return handlerList; 38 | } 39 | 40 | /** 41 | * Get the loser. 42 | * 43 | * @return null, if {@link #getResult()} returns {@link WarResult#DRAW} 44 | */ 45 | @Nullable 46 | public MemberHolder getLoser() { 47 | return winner == null ? null : war.getEnemy(winner); 48 | } 49 | 50 | /** 51 | * Get the result of this war. 52 | * @return result of this war 53 | */ 54 | @NotNull 55 | public WarResult getResult() { 56 | return warResult; 57 | } 58 | 59 | /** 60 | * Get the winner. 61 | * 62 | * @return null, if {@link #getResult()} returns {@link WarResult#DRAW} 63 | */ 64 | @Nullable 65 | public MemberHolder getWinner() { 66 | return winner; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/war/WarEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.war; 2 | 3 | import com.github.angeschossen.pluginframework.api.utils.Checks; 4 | import com.google.common.collect.ImmutableMap; 5 | import me.angeschossen.lands.api.events.plugin.LandsEvent; 6 | import me.angeschossen.lands.api.war.War; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | import java.util.Collection; 10 | import java.util.UUID; 11 | 12 | /** 13 | * Used for events that affect a war. 14 | */ 15 | public abstract class WarEvent extends LandsEvent { 16 | 17 | protected final @NotNull War war; 18 | 19 | public WarEvent(@NotNull War war) { 20 | Checks.requireNonNull(war, "war"); 21 | this.war = war; 22 | } 23 | 24 | /** 25 | * Get the affected war. 26 | * 27 | * @return never null 28 | */ 29 | @NotNull 30 | public War getWar() { 31 | return war; 32 | } 33 | 34 | @Override 35 | public void setAffectedPlayers(ImmutableMap.@NotNull Builder> builder) { 36 | war.setAffectedPlayers("war_", builder); 37 | } 38 | 39 | @Override 40 | public void setExpressionVariables(ImmutableMap.@NotNull Builder builder) { 41 | war.setExpressionVariables("war_", builder, null); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/war/WarStartEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.war; 2 | 3 | import me.angeschossen.lands.api.war.War; 4 | import org.bukkit.event.HandlerList; 5 | import org.jetbrains.annotations.NotNull; 6 | 7 | /** 8 | * Called when a war starts. This might be after the configured preparation time. 9 | * The preparation time is configured by the server in the configuration. The preparation time starts after 10 | * a declaration has been sent or has been accepted if the server has mututal declarations enabled. 11 | * @see WarDeclareEvent 12 | */ 13 | public class WarStartEvent extends WarEvent { 14 | public static HandlerList handlerList = new HandlerList(); 15 | 16 | /** 17 | * Constructor 18 | * @param war the affected war 19 | */ 20 | public WarStartEvent(@NotNull War war) { 21 | super(war); 22 | } 23 | 24 | public static HandlerList getHandlerList() { 25 | return handlerList; 26 | } 27 | 28 | @Override 29 | public @NotNull HandlerList getHandlers() { 30 | return handlerList; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/war/captureflag/CaptureFlagCapturedEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.war.captureflag; 2 | 3 | import me.angeschossen.lands.api.events.war.captureflag.base.CaptureFlagEvent; 4 | import me.angeschossen.lands.api.war.captureflag.CaptureFlag; 5 | import org.bukkit.event.HandlerList; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | /** 9 | * Called whenever a capture flag has been captured successfully. 10 | * If you want to prevent a team from capturing a flag, cancel {@link CaptureFlagProgressEvent} instead. 11 | */ 12 | public class CaptureFlagCapturedEvent extends CaptureFlagEvent { 13 | 14 | public static HandlerList handlerList = new HandlerList(); 15 | 16 | /** 17 | * Create instance of this event. 18 | * @param captureFlag the captured flag 19 | */ 20 | public CaptureFlagCapturedEvent(@NotNull CaptureFlag captureFlag) { 21 | super(captureFlag, null); 22 | } 23 | 24 | public static HandlerList getHandlerList() { 25 | return handlerList; 26 | } 27 | 28 | @NotNull 29 | @Override 30 | public HandlerList getHandlers() { 31 | return handlerList; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/war/captureflag/CaptureFlagProgressEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.war.captureflag; 2 | 3 | import com.github.angeschossen.pluginframework.api.utils.Checks; 4 | import me.angeschossen.lands.api.events.war.captureflag.base.CaptureFlagCancellableEvent; 5 | import me.angeschossen.lands.api.war.captureflag.CaptureFlag; 6 | import me.angeschossen.lands.api.war.enums.WarTeam; 7 | import org.bukkit.event.HandlerList; 8 | import org.jetbrains.annotations.NotNull; 9 | 10 | /** 11 | * Called whenever a team makes progress at capturing a flag or capturing it back from the attackers. 12 | */ 13 | public class CaptureFlagProgressEvent extends CaptureFlagCancellableEvent { 14 | public static HandlerList handlerList = new HandlerList(); 15 | 16 | private @NotNull WarTeam progressor; 17 | 18 | /** 19 | * Create instance of this event. 20 | * 21 | * @param captureFlag the flag that is being captured 22 | * @param progressor the progressor 23 | */ 24 | public CaptureFlagProgressEvent(@NotNull CaptureFlag captureFlag, @NotNull WarTeam progressor) { 25 | super(captureFlag, null); 26 | 27 | this.progressor = Checks.requireNonNull(progressor, "progressorTeam"); 28 | } 29 | 30 | /** 31 | * Get the team that is capturing the flag. 32 | * 33 | * @return if team equals {@link WarTeam#DEFENDER}, the defenders are capturing the flag back. Will never be {@link WarTeam#NEUTRAL} 34 | */ 35 | public @NotNull WarTeam getProgressor() { 36 | return progressor; 37 | } 38 | 39 | public static HandlerList getHandlerList() { 40 | return handlerList; 41 | } 42 | 43 | @NotNull 44 | @Override 45 | public HandlerList getHandlers() { 46 | return handlerList; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/war/captureflag/base/CaptureFlagCancellableEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.war.captureflag.base; 2 | 3 | import me.angeschossen.lands.api.player.LandPlayer; 4 | import me.angeschossen.lands.api.war.captureflag.CaptureFlag; 5 | import org.bukkit.event.Cancellable; 6 | import org.jetbrains.annotations.NotNull; 7 | import org.jetbrains.annotations.Nullable; 8 | 9 | /** 10 | * Used for events that effect a capture flag. 11 | */ 12 | public abstract class CaptureFlagCancellableEvent extends CaptureFlagEvent implements Cancellable { 13 | private boolean cancelled; 14 | 15 | /** 16 | * Constructor 17 | * @param captureFlag the affected capture flag 18 | * @param player if null, no player is involved in triggering this event 19 | */ 20 | public CaptureFlagCancellableEvent(@NotNull CaptureFlag captureFlag, @Nullable LandPlayer player) { 21 | super(captureFlag, player); 22 | } 23 | 24 | @Override 25 | public boolean isCancelled() { 26 | return this.cancelled; 27 | } 28 | 29 | @Override 30 | public void setCancelled(boolean cancelled) { 31 | this.cancelled = cancelled; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/events/war/captureflag/base/CaptureFlagEvent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.events.war.captureflag.base; 2 | 3 | import com.google.common.collect.ImmutableMap; 4 | import me.angeschossen.lands.api.events.war.WarEvent; 5 | import me.angeschossen.lands.api.player.LandPlayer; 6 | import me.angeschossen.lands.api.war.captureflag.CaptureFlag; 7 | import org.jetbrains.annotations.NotNull; 8 | import org.jetbrains.annotations.Nullable; 9 | 10 | import java.util.Collection; 11 | import java.util.UUID; 12 | 13 | /** 14 | * Used for events that effect a capture flag. 15 | */ 16 | public abstract class CaptureFlagEvent extends WarEvent { 17 | protected final @Nullable LandPlayer player; 18 | protected final @NotNull CaptureFlag captureFlag; 19 | 20 | /** 21 | * Constructor 22 | * 23 | * @param captureFlag the affected capture flag 24 | * @param player if null, no player is involved in triggering this event 25 | */ 26 | public CaptureFlagEvent(@NotNull CaptureFlag captureFlag, @Nullable LandPlayer player) { 27 | super(captureFlag.getWar()); 28 | 29 | this.player = player; 30 | this.captureFlag = captureFlag; 31 | } 32 | 33 | /** 34 | * Get the flag that is affected by this event. 35 | * 36 | * @return never null 37 | */ 38 | public @NotNull CaptureFlag getCaptureFlag() { 39 | return captureFlag; 40 | } 41 | 42 | /** 43 | * Get the player involved. 44 | * 45 | * @return if null, no player involved 46 | */ 47 | @Nullable 48 | public LandPlayer getLandPlayer() { 49 | return player; 50 | } 51 | 52 | @Override 53 | public void setAffectedPlayers(ImmutableMap.@NotNull Builder> builder) { 54 | super.setAffectedPlayers(builder); 55 | 56 | if (player != null) { 57 | player.setAffectedPlayers("placer_", builder); 58 | } 59 | } 60 | 61 | @Override 62 | public void setExpressionVariables(ImmutableMap.@NotNull Builder builder) { 63 | super.setExpressionVariables(builder); 64 | 65 | if (player != null) { 66 | final UUID uuid = player.getUID(); 67 | player.setExpressionVariables("placer_", builder, uuid); 68 | captureFlag.setExpressionVariables("flag_", builder, uuid); 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/exceptions/FlagConflictException.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.exceptions; 2 | 3 | 4 | import me.angeschossen.lands.api.flags.type.parent.Flag; 5 | import org.jetbrains.annotations.NotNull; 6 | 7 | import java.util.Objects; 8 | 9 | /** 10 | * Thrown when you try to register a flag, which name is already taken by a different flag. 11 | */ 12 | public class FlagConflictException extends RuntimeException { 13 | 14 | private final @NotNull Flag existing; 15 | 16 | /** 17 | * Create instance. 18 | * 19 | * @param existing the existing flag 20 | * @param message message to throw 21 | */ 22 | public FlagConflictException(@NotNull Flag existing, @NotNull String message) { 23 | super(message); 24 | 25 | Objects.requireNonNull(existing, "existing flag can't be null"); 26 | this.existing = existing; 27 | } 28 | 29 | /** 30 | * Get the existing flag, which already has the provided name. 31 | * 32 | * @return the existing flag 33 | */ 34 | @NotNull 35 | public Flag getExisting() { 36 | return existing; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/exceptions/LandAlreadyInNationException.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.exceptions; 2 | 3 | /** 4 | * Thrown if a land is part of a nation and you try to add it to another nation. 5 | */ 6 | public class LandAlreadyInNationException extends RuntimeException { 7 | 8 | /** 9 | * Create instance. 10 | */ 11 | public LandAlreadyInNationException() { 12 | super("This land is already part of a nation."); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/exceptions/ManagedByDifferentHolderException.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.exceptions; 2 | 3 | /** 4 | * Thrown if a player tries to edit a role that is for example managed by the nation and not by the land. 5 | */ 6 | public class ManagedByDifferentHolderException extends RuntimeException { 7 | /** 8 | * Create instance. 9 | * @param errorMessage The error message 10 | */ 11 | public ManagedByDifferentHolderException(String errorMessage) { 12 | super(errorMessage); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/flags/DefaultStateFlag.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.flags; 2 | 3 | import org.bukkit.plugin.Plugin; 4 | import org.jetbrains.annotations.NotNull; 5 | 6 | /** 7 | * Use {@link me.angeschossen.lands.api.flags.type.parent.DefaultStateFlag} instead. 8 | */ 9 | @Deprecated 10 | public abstract class DefaultStateFlag extends Flag implements me.angeschossen.lands.api.flags.type.parent.DefaultStateFlag { 11 | 12 | protected boolean defaultState; 13 | 14 | public DefaultStateFlag(@NotNull Plugin plugin, @NotNull Target target, @NotNull String name, boolean applyInSubAreas, boolean alwaysAllowInWilderness) { 15 | super(plugin, target, name, applyInSubAreas, alwaysAllowInWilderness); 16 | } 17 | 18 | @Override 19 | public final boolean getDefaultState() { 20 | return defaultState; 21 | } 22 | 23 | @NotNull 24 | @Override 25 | public final DefaultStateFlag setDefaultState(boolean defaultState) { 26 | this.defaultState = defaultState; 27 | return this; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/flags/enums/FlagModule.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.flags.enums; 2 | 3 | /** 4 | * There are different major features in Lands which could be called modules since they're modular. 5 | * Some of these modules might have flags. 6 | */ 7 | public enum FlagModule { 8 | /** 9 | * Players will use these flags for roles. 10 | */ 11 | LAND, 12 | /** 13 | * This flag is related to nations. 14 | */ 15 | NATION, 16 | /** 17 | * This flag only applies to a player's personal settings. 18 | */ 19 | PLAYER 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/flags/enums/FlagTarget.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.flags.enums; 2 | 3 | /** 4 | * Some flags are not accessible for player or even admins. 5 | */ 6 | public enum FlagTarget { 7 | /** 8 | * Accessible for all players. 9 | */ 10 | PLAYER, 11 | /** 12 | * Only for admin lands. 13 | */ 14 | ADMIN, 15 | /** 16 | * Only used by Lands itself. Not accessible for players of admin lands. 17 | */ 18 | SYSTEM 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/flags/enums/RoleFlagCategory.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.flags.enums; 2 | 3 | /** 4 | * There are two role flag categories. 5 | */ 6 | public enum RoleFlagCategory { 7 | /** 8 | * Physical actions, such as block breaking etc. 9 | */ 10 | ACTION, 11 | /** 12 | * Management operations such as trusting a player etc. 13 | */ 14 | MANAGEMENT 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/flags/type/NaturalFlag.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.flags.type; 2 | 3 | import me.angeschossen.lands.api.LandsIntegration; 4 | import me.angeschossen.lands.api.flags.enums.FlagTarget; 5 | import me.angeschossen.lands.api.flags.type.parent.DefaultStateFlag; 6 | import me.angeschossen.lands.api.flags.type.parent.Flag; 7 | import me.angeschossen.lands.api.handler.APIHandler; 8 | import org.jetbrains.annotations.NotNull; 9 | 10 | /** 11 | * Natural flags are used for events that don't primarily involve a player. For example an exploding tnt etc. 12 | */ 13 | public interface NaturalFlag extends Flag, DefaultStateFlag { 14 | 15 | /** 16 | * Create instance of a natural flag. 17 | * 18 | * @param landsIntegration the integration 19 | * @param flagTarget target of the flag 20 | * @param name unique name of the flag 21 | * @return created flag instance 22 | */ 23 | @NotNull 24 | static NaturalFlag of(@NotNull LandsIntegration landsIntegration, @NotNull FlagTarget flagTarget, @NotNull String name) { 25 | return APIHandler.getFlagFactory().naturalFlagOf(landsIntegration, flagTarget, name); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/flags/type/PlayerFlag.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.flags.type; 2 | 3 | import me.angeschossen.lands.api.flags.type.parent.DefaultStateFlag; 4 | 5 | /** 6 | * Player flags are used for player's personal settings. 7 | */ 8 | public interface PlayerFlag extends DefaultStateFlag { 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/flags/type/parent/DefaultStateFlag.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.flags.type.parent; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | /** 6 | * Flags that have a default state. 7 | * @param the flag implementation 8 | */ 9 | public interface DefaultStateFlag extends Flag { 10 | 11 | /** 12 | * Get the default state. 13 | * @return true, if flag is enabled by default. 14 | */ 15 | boolean getDefaultState(); 16 | 17 | /** 18 | * Set the default state. 19 | * @param state true, if flag should be enabled by default 20 | * @return instance of this flag 21 | */ 22 | @NotNull 23 | DefaultStateFlag setDefaultState(boolean state); 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/flags/types/LandFlag.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.flags.types; 2 | 3 | import me.angeschossen.lands.api.flags.DefaultStateFlag; 4 | import me.angeschossen.lands.api.flags.Flag; 5 | import me.angeschossen.lands.api.flags.enums.FlagModule; 6 | import me.angeschossen.lands.api.flags.type.NaturalFlag; 7 | import me.angeschossen.lands.api.handler.APIHandler; 8 | import org.bukkit.plugin.Plugin; 9 | import org.jetbrains.annotations.NotNull; 10 | 11 | import java.util.Objects; 12 | 13 | /** 14 | * Use {@link NaturalFlag} instead. 15 | */ 16 | @Deprecated 17 | public class LandFlag extends DefaultStateFlag implements NaturalFlag { 18 | 19 | @Override 20 | protected LandFlag self() { 21 | return this; 22 | } 23 | 24 | /** 25 | * @param plugin Your plugin. 26 | * @param name The name of the flag. 27 | * @param applyInSubAreas Should this flag also be available in sub areas, not just the land in general? 28 | * @param alwaysAllowInWilderness Should this flag always be true in wilderness? 29 | * @param target Only admin lands or all lands. 30 | */ 31 | public LandFlag(@NotNull Plugin plugin, @NotNull Target target, @NotNull String name, boolean applyInSubAreas, boolean alwaysAllowInWilderness) { 32 | super(plugin, target, name, applyInSubAreas, alwaysAllowInWilderness); 33 | } 34 | 35 | public static LandFlag of(String name) { 36 | NaturalFlag flag = Objects.requireNonNull(APIHandler.getFlagRegistry().getNatural(name), "legacy flag"); 37 | return new LandFlag(flag.getPlugin(), Flag.Target.valueOf(flag.getTarget().toString()), flag.getName(), flag.isApplyInSubareas(), flag.isAlwaysAllowInWilderness()); 38 | } 39 | 40 | @Deprecated 41 | public LandFlag(@NotNull Plugin plugin, @NotNull String name, boolean applyInSubAreas) { 42 | this(plugin, Target.PLAYER, name, applyInSubAreas, false); 43 | } 44 | 45 | public LandFlag(@NotNull Plugin plugin, @NotNull String name) { 46 | this(plugin, Target.PLAYER, name, true, false); 47 | } 48 | 49 | 50 | @NotNull 51 | @Override 52 | public final FlagModule getModule() { 53 | return FlagModule.LAND; 54 | } 55 | 56 | @Override 57 | public final @NotNull String getTogglePerm() { 58 | return "lands.setting." + name; 59 | } 60 | 61 | @Override 62 | public @NotNull String getTogglePermission() { 63 | return getTogglePerm(); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/flags/types/NationRoleFlag.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.flags.types; 2 | 3 | import me.angeschossen.lands.api.flags.enums.FlagModule; 4 | import org.bukkit.plugin.Plugin; 5 | import org.jetbrains.annotations.NotNull; 6 | 7 | /** 8 | * No longer needed. 9 | */ 10 | @Deprecated 11 | public class NationRoleFlag extends RoleFlag { 12 | 13 | public NationRoleFlag(@NotNull Plugin plugin, @NotNull String name) { 14 | super(plugin, Category.MANAGEMENT, name, false, true); 15 | } 16 | 17 | @Override 18 | public final @NotNull String getTogglePerm() { 19 | return "nations.setting." + name; 20 | } 21 | 22 | @Override 23 | public final @NotNull String getBypassPerm() { 24 | return "nations.bypass." + name; 25 | } 26 | 27 | @Override 28 | public final @NotNull String getBypassPermWild() { 29 | return "nations.bypass.wilderness." + name; 30 | } 31 | 32 | @Override 33 | @NotNull 34 | public final FlagModule getModule() { 35 | return FlagModule.NATION; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/flags/types/PlayerFlag.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.flags.types; 2 | 3 | import me.angeschossen.lands.api.flags.DefaultStateFlag; 4 | import me.angeschossen.lands.api.flags.enums.FlagModule; 5 | import me.angeschossen.lands.api.handler.APIHandler; 6 | import org.bukkit.plugin.Plugin; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | import java.util.Objects; 10 | 11 | /** 12 | * Use {@link me.angeschossen.lands.api.flags.type.PlayerFlag} instead. 13 | */ 14 | @Deprecated 15 | public class PlayerFlag extends DefaultStateFlag implements me.angeschossen.lands.api.flags.type.PlayerFlag { 16 | 17 | public PlayerFlag(@NotNull Plugin plugin, @NotNull String name) { 18 | super(plugin, Target.PLAYER, name, true, false); 19 | } 20 | 21 | @Override 22 | public @NotNull FlagModule getModule() { 23 | return FlagModule.PLAYER; 24 | } 25 | 26 | @Override 27 | protected PlayerFlag self() { 28 | return this; 29 | } 30 | 31 | public static PlayerFlag of(String name) { 32 | me.angeschossen.lands.api.flags.type.PlayerFlag flag = Objects.requireNonNull(APIHandler.getFlagRegistry().getPlayer(name), "legacy flag: " + name); 33 | return new PlayerFlag(flag.getPlugin(), flag.getName()); 34 | } 35 | 36 | @Override 37 | public @NotNull String getTogglePerm() { 38 | return "lands.player.setting." + name; 39 | } 40 | 41 | @Override 42 | public @NotNull String getTogglePermission() { 43 | return getTogglePerm(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/handler/FlagFactory.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.handler; 2 | 3 | import me.angeschossen.lands.api.LandsIntegration; 4 | import me.angeschossen.lands.api.exceptions.FlagConflictException; 5 | import me.angeschossen.lands.api.flags.enums.FlagTarget; 6 | import me.angeschossen.lands.api.flags.enums.RoleFlagCategory; 7 | import me.angeschossen.lands.api.flags.type.NaturalFlag; 8 | import me.angeschossen.lands.api.flags.type.RoleFlag; 9 | import org.jetbrains.annotations.NotNull; 10 | 11 | /** 12 | * This interface is not intended for direct usage and might change at any time. 13 | */ 14 | public interface FlagFactory { 15 | 16 | @NotNull RoleFlag roleFlagOf(@NotNull LandsIntegration plugin, @NotNull FlagTarget flagTarget, @NotNull RoleFlagCategory category, @NotNull String name) throws FlagConflictException, IllegalArgumentException; 17 | 18 | @NotNull NaturalFlag naturalFlagOf(@NotNull LandsIntegration plugin, @NotNull FlagTarget flagTarget, @NotNull String name) throws FlagConflictException, IllegalArgumentException; 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/handler/LandsIntegrationFactory.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.handler; 2 | 3 | import com.github.angeschossen.pluginframework.api.blockutil.BlockPosition; 4 | import me.angeschossen.lands.api.LandsIntegration; 5 | import me.angeschossen.lands.api.inbox.InboxCategory; 6 | import me.angeschossen.lands.api.inbox.InboxMessage; 7 | import me.angeschossen.lands.api.items.ItemType; 8 | import me.angeschossen.lands.api.land.Land; 9 | import me.angeschossen.lands.api.land.block.LandMainBlock; 10 | import me.angeschossen.lands.api.land.enums.LandType; 11 | import me.angeschossen.lands.api.memberholder.MemberHolder; 12 | import me.angeschossen.lands.api.player.LandPlayer; 13 | import me.angeschossen.lands.api.player.Selection; 14 | import me.angeschossen.lands.api.player.combat.CombatTag; 15 | import me.angeschossen.lands.api.role.Role; 16 | import me.angeschossen.lands.api.role.RoleHolder; 17 | import org.bukkit.Location; 18 | import org.bukkit.inventory.ItemStack; 19 | import org.bukkit.plugin.Plugin; 20 | import org.jetbrains.annotations.NotNull; 21 | import org.jetbrains.annotations.Nullable; 22 | 23 | import java.util.concurrent.CompletableFuture; 24 | 25 | /** 26 | * This interface is not intended for direct usage and might change at any time. 27 | */ 28 | public interface LandsIntegrationFactory { 29 | 30 | @NotNull 31 | LandsIntegration of(@NotNull Plugin plugin); 32 | 33 | ItemStack buildItemStack(@NotNull ItemType itemType, @Nullable LandPlayer landPlayer); 34 | 35 | ItemStack buildCampItem(@Nullable LandPlayer landPlayer, int radius); 36 | 37 | @NotNull 38 | CombatTag combatTagOf(@NotNull LandsIntegration landsIntegration, @NotNull LandPlayer attacker, LandPlayer target, long duration, boolean showMessage); 39 | 40 | @NotNull 41 | InboxMessage inboxMessageOf(@NotNull LandsIntegration landsIntegration, @NotNull MemberHolder memberHolder, @NotNull InboxCategory category, @NotNull String key, @Nullable String[] placeholders, String[] placeholderValues, boolean isAlert, boolean broadcast, @Nullable LandPlayer filterReceive); 42 | 43 | @NotNull 44 | Role roleOf(@NotNull RoleHolder roleHolder, @NotNull String name) throws IllegalArgumentException, IllegalStateException; 45 | 46 | @NotNull 47 | CompletableFuture landOf(@NotNull String name, @NotNull LandType landType, @NotNull Location location, @NotNull LandPlayer owner, boolean claim, boolean msg); 48 | 49 | LandMainBlock landMainBlockOf(@Nullable LandPlayer landPlayer, @NotNull BlockPosition blockPosition); 50 | 51 | @NotNull 52 | Selection selectionOf(@NotNull LandPlayer landPlayer, boolean giveTool, boolean msg, boolean visualization); 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/handler/MessageHandler.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.handler; 2 | 3 | import com.github.angeschossen.pluginframework.api.configuration.gui.GUIConfiguration; 4 | import com.github.angeschossen.pluginframework.api.configuration.messages.Messages; 5 | import me.angeschossen.lands.api.player.LandPlayer; 6 | import org.jetbrains.annotations.NotNull; 7 | import org.jetbrains.annotations.Nullable; 8 | 9 | /** 10 | * This interface is not intended for direct usage and might change at any time. 11 | */ 12 | public interface MessageHandler { 13 | @NotNull 14 | Messages getMessagesLocale(@Nullable LandPlayer sender); 15 | 16 | @NotNull 17 | GUIConfiguration getGUILocale(@Nullable LandPlayer sender); 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/holders/BalanceHolder.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.holders; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | public interface BalanceHolder { 6 | 7 | /** 8 | * Get the balance. 9 | * @return never negative 10 | */ 11 | double getBalance(); 12 | 13 | /** 14 | * Set the balance 15 | * @param balance The balance will be set to 0 if the provided balance is negative 16 | * @return false, if the provided balance was negative. 17 | */ 18 | boolean setBalance(double balance); 19 | 20 | /** 21 | * Modify the balance by a specific amount. 22 | * @param modify Can be negative to substract that amount 23 | * @return The new balance will never go below 0 24 | */ 25 | boolean modifyBalance(double modify); 26 | boolean modifyBalance(double modify, boolean save); 27 | /** 28 | * Get the balance in a formatted display. 29 | * @return Formatted view of the balance. Depends on the server's config 30 | */ 31 | @NotNull 32 | String getBalanceDisplay(); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/inbox/InboxMessageProvider.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.inbox; 2 | 3 | import com.github.angeschossen.pluginframework.api.player.PlayerData; 4 | import org.jetbrains.annotations.NotNull; 5 | import org.jetbrains.annotations.Nullable; 6 | 7 | /** 8 | * Needed to add custom inbox messages to lands or nation. 9 | */ 10 | public interface InboxMessageProvider { 11 | 12 | /** 13 | * This method is used to retrieve the raw inbox messages by their unique key 14 | * 15 | * @param key unique key 16 | * @param landPlayer The player that is viewing the inbox message. Can be used for multi locale setups. 17 | * If null, the message is retrieved by system to check if its still valid and other purposes. 18 | * @return null, if the message no longer exists and should be deleted at the next server restart 19 | */ 20 | @Nullable 21 | String getRawMessage(@NotNull String key, @Nullable PlayerData landPlayer); 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/items/ItemType.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.items; 2 | 3 | import me.angeschossen.lands.api.handler.APIHandler; 4 | import me.angeschossen.lands.api.player.LandPlayer; 5 | import org.bukkit.inventory.ItemStack; 6 | import org.jetbrains.annotations.NotNull; 7 | import org.jetbrains.annotations.Nullable; 8 | 9 | public enum ItemType { 10 | /** 11 | * Block used to claim the chunk it is being placed in. 12 | */ 13 | CLAIM_BLOCK, 14 | /** 15 | * Block that creates a capture flag upon placement in wars. 16 | */ 17 | CAPTURE_FLAG, 18 | /** 19 | * Block that creates a temporary land. 20 | */ 21 | CAMP { 22 | @Override 23 | public @NotNull ItemStack build(@Nullable LandPlayer owner) { 24 | return build(owner, 1); 25 | } 26 | 27 | @NotNull 28 | public ItemStack build(@Nullable LandPlayer owner, int radius) { 29 | return APIHandler.getLandsIntegrationFactory().buildCampItem(owner, radius); 30 | } 31 | }, 32 | /** 33 | * Tool used to select areas for claiming or sub area creation. 34 | */ 35 | SELECTION, 36 | /** 37 | * Tool used to show info about chunk that it points at. 38 | */ 39 | INFO; 40 | 41 | /** 42 | * Create a new item stack of this type. 43 | * 44 | * @param owner if null, no owner applied to item 45 | * @return never null 46 | */ 47 | @NotNull 48 | public ItemStack build(@Nullable LandPlayer owner) { 49 | return APIHandler.getLandsIntegrationFactory().buildItemStack(this, owner); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/land/ChunkCoordinate.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.land; 2 | 3 | /** 4 | * Represents coordinates of a chunk. 5 | */ 6 | public interface ChunkCoordinate { 7 | 8 | /** 9 | * Get block x. 10 | * 11 | * @return Block x 12 | */ 13 | int getBlockX(); 14 | 15 | 16 | /** 17 | * Get block z. 18 | * 19 | * @return Block z 20 | */ 21 | int getBlockZ(); 22 | 23 | /** 24 | * Get chunk x. 25 | * 26 | * @return Chunk x 27 | */ 28 | int getX(); 29 | 30 | /** 31 | * Get chunk z. 32 | * 33 | * @return Chunk z 34 | */ 35 | int getZ(); 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/land/LandArea.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.land; 2 | 3 | import me.angeschossen.lands.api.blockworks.BoundingBox; 4 | import org.bukkit.World; 5 | import org.jetbrains.annotations.NotNull; 6 | import org.jetbrains.annotations.Nullable; 7 | 8 | /** 9 | * A land area is a sub area inside a land. 10 | * This isn't a {@link Land#getDefaultArea()}. 11 | */ 12 | public interface LandArea extends Area { 13 | 14 | /** 15 | * Get the world. 16 | * @return The world in which this sub area is located in 17 | */ 18 | @Nullable 19 | World getWorld(); 20 | 21 | /** 22 | * Get the bounding box of the sub area. 23 | * 24 | * @return Will return null, if the area isn't setup yet ({@link #isSetup()}). 25 | */ 26 | @Nullable 27 | BoundingBox getBoundingBox(); 28 | 29 | /** 30 | * Set a name for this area. 31 | * @param name The new land. You can include color codes 32 | * @return false, if the land already has an area witht that name 33 | */ 34 | boolean setName(@NotNull String name); 35 | 36 | /** 37 | * Use {@link #getBoundingBox()} instead. 38 | * @param x Block x 39 | * @param y Block y 40 | * @param z Block z 41 | * @return false, if the area doesn't contain this coordinate. 42 | */ 43 | @Deprecated 44 | boolean contains(int x, int y, int z); 45 | 46 | /** 47 | * Check if this area has both corners set. 48 | * @return false, if the area isn't setup yet 49 | */ 50 | boolean isSetup(); 51 | 52 | /** 53 | * Get the claim information of this area. 54 | * @return null, if {@link #isSetup()} returns false 55 | */ 56 | @Nullable Container getContainer(); 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/land/LandCategory.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.land; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * A category can be set to a {@link Land} to singal to other players what the land is about. For example shops, arenas, looking for members etc. 9 | * Each server can define their own categories. 10 | */ 11 | public interface LandCategory { 12 | 13 | /** 14 | * Get the description of this category. 15 | * @return Never null 16 | */ 17 | @NotNull List getDescription(); 18 | 19 | /** 20 | * Get the name of this category. 21 | * @return Might include color codes 22 | */ 23 | @NotNull String getName(); 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/land/SystemFlagStatesHolder.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.land; 2 | 3 | import me.angeschossen.lands.api.player.LandPlayer; 4 | import me.angeschossen.lands.api.role.system.SystemFlagStates; 5 | import org.jetbrains.annotations.NotNull; 6 | 7 | import java.util.UUID; 8 | 9 | public interface SystemFlagStatesHolder { 10 | /** 11 | * Set system flag states for a player. System flag states can only be applied 12 | * to players that aren't trusted. This should only be used if you want some players 13 | * to bypass the regular role system. For example if you want to implement a war system 14 | * that allows players to grief land during war. 15 | *

16 | * It's your responsibility to remove the flag states when they shouldn't be applied anymore. See {@link #removeSystemFlagStates(UUID)} for more info. 17 | * Also they aren't persistent and therefore reset at each server restart. Once the player leaves 18 | * the server they're removed as well. So you need to add your own logic to set them upon login 19 | * and whenever you want to apply them. 20 | * 21 | * @param player the player for which the flags should be set 22 | * @param flagStates collection of flag states 23 | * @throws IllegalStateException if the player is trusted 24 | */ 25 | void setSystemFlagStates(@NotNull LandPlayer player, @NotNull SystemFlagStates flagStates) throws IllegalStateException; 26 | 27 | /** 28 | * Remove system flag states for a player. 29 | * 30 | * @param player the player 31 | */ 32 | void removeSystemFlagStates(@NotNull UUID player); 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/land/TaxHolder.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.land; 2 | 3 | import com.github.angeschossen.pluginframework.api.holder.ChangeSaveable; 4 | import org.bukkit.command.CommandSender; 5 | import org.jetbrains.annotations.NotNull; 6 | import org.jetbrains.annotations.Nullable; 7 | 8 | public interface TaxHolder extends ChangeSaveable { 9 | 10 | /** 11 | * Set tax value. 12 | * 13 | * @param tax New tax value. Can't be negative 14 | */ 15 | void setTax(double tax); 16 | 17 | /** 18 | * Add taxes for this area. 19 | * 20 | * @param tax If negative, it will remove taxes. 21 | * @return New tax value 22 | */ 23 | double addTax(double tax); 24 | 25 | /** 26 | * Get current tax value. 27 | * 28 | * @return Current tax 29 | */ 30 | double getTax(); 31 | 32 | /** 33 | * Get the name of this area. To include color codes, use {@link #getColorName()} instead. 34 | * 35 | * @return Name of the land without color codes 36 | */ 37 | @NotNull 38 | String getName(); 39 | 40 | /** 41 | * Same as {@link #getName()}, but with colors codes included. 42 | * 43 | * @return Name with color codes 44 | */ 45 | @Deprecated 46 | @NotNull 47 | String getColorName(); 48 | 49 | /** 50 | * Same as {@link #getName()}, but with colors codes included. 51 | * 52 | * @return Name with color codes 53 | */ 54 | @NotNull 55 | String getColorName(@Nullable CommandSender sender); 56 | 57 | /** 58 | * Get estimated tax revenue amount. 59 | * @param self UUID of player for {@link Land} and Land for {@link me.angeschossen.lands.api.nation.Nation}. 60 | * @param assumeTrusted Assume the player is trusted or the land is a member of the nation? 61 | * @param before If it should calculate the tax revenue before the latest tax increase 62 | * @return The estimated tax revenue 63 | */ 64 | double getEstimatedTaxRevenue(@Nullable Object self, boolean assumeTrusted, boolean before); 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/land/block/LandBlock.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.land.block; 2 | 3 | import com.github.angeschossen.pluginframework.api.blockutil.impl.BlockPosition; 4 | import me.angeschossen.lands.api.land.Container; 5 | import org.jetbrains.annotations.NotNull; 6 | import org.jetbrains.annotations.Nullable; 7 | 8 | /** 9 | * Special blocks that can be placed inside a land. 10 | */ 11 | public interface LandBlock { 12 | /** 13 | * Get the unique Id of this block. 14 | * 15 | * @return unique id 16 | */ 17 | @NotNull String getId(); 18 | 19 | /** 20 | * Get the container in which the landblock is placed in. 21 | * 22 | * @return never null. A landblock needs to be placed inside a land 23 | */ 24 | @NotNull Container getContainer(); 25 | 26 | /** 27 | * Get the center of the structure. 28 | * 29 | * @return center of the structure 30 | */ 31 | @NotNull 32 | BlockPosition getCenter(); 33 | 34 | /** 35 | * Check if the structure contains a block coordinate. 36 | * 37 | * @param x Block x 38 | * @param y Block y 39 | * @param z Block z 40 | * @return true, if the block belongs to the structure 41 | */ 42 | boolean containsBlock(int x, int y, int z); 43 | 44 | /** 45 | * Get the type of this block. 46 | * 47 | * @return type of the block 48 | */ 49 | @NotNull LandBlockType getType(); 50 | 51 | /** 52 | * @param done will be executed once all blocks are removed 53 | * @param delayTicks remove a block each x ticks. So if the landblock 54 | * consists of 5 blocks it will take 5 * x ticks to remove the complete landblock. 55 | * @return false, if a 3rd party plugin cancelled the removal of the landblock 56 | */ 57 | boolean remove(@Nullable Runnable done, int delayTicks); 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/land/block/LandBlockType.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.land.block; 2 | 3 | public enum LandBlockType { 4 | /** 5 | * The mainblock, which opens the land menu and land storage upon interaction. 6 | */ 7 | MAIN, 8 | /** 9 | * The mainblock for camps. 10 | */ 11 | MAIN_CAMP, 12 | /** 13 | * Capture flag during war. 14 | */ 15 | CAPTURE_FLAG, 16 | /** 17 | * Rental sign or rental hologram 18 | */ 19 | RENTAL 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/land/block/LandMainBlock.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.land.block; 2 | 3 | import com.github.angeschossen.pluginframework.api.blockutil.BlockPosition; 4 | import me.angeschossen.lands.api.handler.APIHandler; 5 | import me.angeschossen.lands.api.player.LandPlayer; 6 | import org.jetbrains.annotations.NotNull; 7 | import org.jetbrains.annotations.Nullable; 8 | 9 | public interface LandMainBlock extends LandBlock { 10 | 11 | /** 12 | * Create a mainblock at this position. 13 | * 14 | * @param landPlayer the player that creates the block. null, if no player involved 15 | * @param position the position of the mainblock 16 | * @return null, if a 3rd party plugin cancels the placement of the mainblock 17 | * @throws IllegalStateException if this isn't called sync, the chunk of the position isn't loaded or the land already has a mainblock 18 | * @throws IllegalArgumentException if there's no claimed land at the position or the land already has a mainblock 19 | */ 20 | @Nullable 21 | static LandMainBlock of(@Nullable LandPlayer landPlayer, @NotNull BlockPosition position) throws IllegalArgumentException, IllegalStateException { 22 | return APIHandler.getLandsIntegrationFactory().landMainBlockOf(landPlayer, position); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/land/block/removalreason/BlockRemovalReason.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.land.block.removalreason; 2 | 3 | /** 4 | * Reasons for landblock removal. 5 | */ 6 | public enum BlockRemovalReason implements LandBlockRemovalReason { 7 | /** 8 | * The landblock doesn't exist any longer in the world. 9 | */ 10 | BLOCK_INVALID, 11 | /** 12 | * The land got unclaimed in which the landblock stood. 13 | */ 14 | LAND_UNCLAIM, 15 | /** 16 | * The landblock got broken by a player. 17 | */ 18 | BLOCK_BREAK 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/land/block/removalreason/LandBlockRemovalReason.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.land.block.removalreason; 2 | 3 | public interface LandBlockRemovalReason { 4 | } 5 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/land/enums/LandGetMode.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.land.enums; 2 | 3 | /** 4 | * Used to evaluate which land to use for commands etc. 5 | * This is needed if a player is part of multiple lands. 6 | */ 7 | public enum LandGetMode { 8 | /** 9 | * The land at the player's position is used for the command execution. 10 | */ 11 | POSITION, 12 | /** 13 | * The "/lands edit" land is used. 14 | */ 15 | EDIT, 16 | /** 17 | * Depending on the server's config, either {@link #POSITION} or {@link #EDIT} is used. 18 | */ 19 | CONFIG 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/land/enums/LandType.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.land.enums; 2 | 3 | /** 4 | * There are different types of lands. 5 | */ 6 | public enum LandType { 7 | /** 8 | * Normal player land. Used at "/lands create". 9 | */ 10 | LAND(0), 11 | /** 12 | * The normal land ({@link #LAND} was converted into an admin land. 13 | * Lands of this type, are not owned by any player. 14 | * Admin lands can set special flags and can't engage in wars. 15 | * However, they can still be part of a nation. 16 | */ 17 | ADMIN(1), 18 | /** 19 | * A camp is a temporary land that will be deleted once it expires. 20 | * This is great for starters that simply want to protect their chests or initial base. 21 | */ 22 | CAMP(2); 23 | 24 | private static final LandType[] map = new LandType[]{LAND, ADMIN, CAMP}; 25 | 26 | public final int id; 27 | 28 | LandType(int id) { 29 | this.id = id; 30 | } 31 | 32 | /** 33 | * Get the land type by its ID. 34 | * @param id The ID 35 | * @return This will return {@link #LAND} if there's no type with this ID 36 | */ 37 | public static LandType getById(int id) { 38 | if (id >= map.length) { 39 | return LAND; 40 | } 41 | 42 | return map[id]; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/land/enums/SettingMode.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.land.enums; 2 | 3 | @Deprecated 4 | public enum SettingMode { 5 | 6 | GLOBAL, LAND 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/land/enums/SortMode.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.land.enums; 2 | 3 | /** 4 | * Use {@link me.angeschossen.lands.api.sorting.Sorting} instead. 5 | */ 6 | @Deprecated 7 | public enum SortMode { 8 | 9 | CHUNKS("chunks"), BALANCE("balance"), MEMBERS("members"), LEVEL("level"); 10 | 11 | public final String name; 12 | public boolean enabled = true; 13 | 14 | SortMode(String name) { 15 | this.name = name; 16 | } 17 | } -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/land/rental/InfoType.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.land.rental; 2 | 3 | /** 4 | * Used to determine display options for rental info. 5 | */ 6 | public enum InfoType { 7 | /** 8 | * Display info as a hologram. 9 | */ 10 | HOLOGRAM(3), 11 | /** 12 | * Get info for signs. 13 | */ 14 | SIGN(1), 15 | /** 16 | * Get info for chat. 17 | */ 18 | CHAT(3); 19 | 20 | private final int maxTimeLength; 21 | 22 | InfoType(int maxTimeLength) { 23 | this.maxTimeLength = maxTimeLength; 24 | } 25 | 26 | /** 27 | * Defines the max amount of time units. 28 | * 29 | * @return if 1 it will only display x days or x hours etc. instead of 1 hour, 5 minutes etc. 30 | */ 31 | public int getMaxTimeLength() { 32 | return maxTimeLength; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/land/rental/offer/base/AcceptedRentalOfferBase.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.land.rental.offer.base; 2 | 3 | /** 4 | * Provides information about a accepted offer. 5 | * */ 6 | public interface AcceptedRentalOfferBase extends RentalBase { 7 | 8 | /** 9 | * Get the compensation that is paid to the tenant, if the land cancels the rental before it expires. 10 | * 11 | * @return compensation that is paid to the tenant 12 | */ 13 | double getCompensation(); 14 | 15 | /** 16 | * Expire the accepted offer to cancel a active rental. 17 | * 18 | * @return false, if cancelled by a 3rd party plugin 19 | */ 20 | boolean expire(); 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/land/rental/offer/base/RentalBase.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.land.rental.offer.base; 2 | 3 | import me.angeschossen.lands.api.land.Area; 4 | import me.angeschossen.lands.api.land.Land; 5 | import me.angeschossen.lands.api.land.block.LandBlock; 6 | import me.angeschossen.lands.api.land.rental.InfoType; 7 | import me.angeschossen.lands.api.land.rental.offer.types.RentalType; 8 | import me.angeschossen.lands.api.player.LandPlayer; 9 | import org.jetbrains.annotations.NotNull; 10 | import org.jetbrains.annotations.Nullable; 11 | 12 | import java.util.List; 13 | 14 | public interface RentalBase { 15 | /** 16 | * Get the type of rental or purchase. 17 | * 18 | * @return never null 19 | */ 20 | @NotNull 21 | RentalType getType(); 22 | 23 | /** 24 | * Get the cost of this offer. 25 | * 26 | * @return the cost to purchase or rent it 27 | */ 28 | double getCost(); 29 | 30 | /** 31 | * Get the size in blocks of the area or land. 32 | * 33 | * @return size in blocks 34 | */ 35 | long getSize(); 36 | 37 | /** 38 | * Get the offer sign or hologram. 39 | * 40 | * @return null, if the sign or hologram no longer exists. 41 | */ 42 | @Nullable LandBlock getBlock(); 43 | 44 | /** 45 | * Get the area that is being sold or being set for rental. 46 | * 47 | * @return If this is the default area ({@link Land#getDefaultArea()}, the whole land is being sold. 48 | */ 49 | @NotNull Area getArea(); 50 | 51 | /** 52 | * Send information about this offer to a player. 53 | * 54 | * @param player the recipient 55 | */ 56 | void sendInfo(@NotNull LandPlayer player); 57 | 58 | /** 59 | * Get the info lines for holograms etc. 60 | * 61 | * @param infoType the type of display 62 | * @return all info lines 63 | */ 64 | @NotNull 65 | List getInfoLines(@NotNull InfoType infoType); 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/land/rental/offer/base/RentalOfferBase.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.land.rental.offer.base; 2 | 3 | /** 4 | * Provides information about an rental or sell offer. 5 | */ 6 | public interface RentalOfferBase extends RentalBase { 7 | 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/land/rental/offer/types/RentOffer.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.land.rental.offer.types; 2 | 3 | import me.angeschossen.lands.api.land.rental.offer.base.RentalOfferBase; 4 | 5 | public interface RentOffer extends RentalOfferBase { 6 | /** 7 | * Get the amount of minutes for each renewal interval. 8 | * 9 | * @return amount of minutes for each renewal interval 10 | */ 11 | int getMinutes(); 12 | 13 | /** 14 | * Get the maximum rental time. 15 | * 16 | * @return max. rental time 17 | */ 18 | int getMaxMinutes(); 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/land/rental/offer/types/RentalType.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.land.rental.offer.types; 2 | 3 | public enum RentalType { 4 | /** 5 | * The offer is to rent a sub area. 6 | * See {@link RentOffer} 7 | */ 8 | RENT, 9 | /** 10 | * The sub areas is rented. 11 | * See {@link RentedState} 12 | */ 13 | RENTED, 14 | /** 15 | * The offer is to purchase a sub area or a whole land. 16 | * See {@link SellOffer} 17 | */ 18 | SELL, 19 | /** 20 | * The sub area or land is sold. 21 | * See {@link SoldState} 22 | */ 23 | SOLD; 24 | 25 | /** 26 | * Check if rental is completed. 27 | * 28 | * @return true if completed 29 | */ 30 | public boolean isCompleted() { 31 | return this == SOLD || this == RENTED; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/land/rental/offer/types/RentedState.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.land.rental.offer.types; 2 | 3 | import me.angeschossen.lands.api.land.rental.offer.base.AcceptedRentalOfferBase; 4 | 5 | public interface RentedState extends RentOffer, AcceptedRentalOfferBase { 6 | /** 7 | * Get the rented and already paid minutes. 8 | * 9 | * @return rented and paid minutes 10 | */ 11 | int getRentedMinutes(); 12 | 13 | /** 14 | * Add or remove minutes to the rental time. 15 | * 16 | * @param minutes can be negative to remove time 17 | */ 18 | void modifyRentedMinutes(int minutes); 19 | 20 | /** 21 | * Get the maximum amount of minutes that can be added by the tenant. 22 | * {@link #modifyRentedMinutes(int)} bypasses this 23 | * 24 | * @return never negative 25 | */ 26 | int getMaxAdditiveMinutes(); 27 | 28 | /** 29 | * Check if the offer is removed after the rental expires. 30 | * 31 | * @return if true, the rental offer will be completely removed after the rental expired 32 | */ 33 | boolean isRemoveAfterExpiration(); 34 | 35 | /** 36 | * Make the offer be removed after the rental expired. 37 | * 38 | * @param value if true, the rental offer will be removed once the rental expires 39 | */ 40 | void setRemoveAfterExpiration(boolean value); 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/land/rental/offer/types/SellOffer.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.land.rental.offer.types; 2 | 3 | import me.angeschossen.lands.api.land.rental.offer.base.RentalOfferBase; 4 | 5 | public interface SellOffer extends RentalOfferBase { 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/land/rental/offer/types/SoldState.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.land.rental.offer.types; 2 | 3 | import me.angeschossen.lands.api.land.rental.offer.base.AcceptedRentalOfferBase; 4 | 5 | public interface SoldState extends SellOffer, AcceptedRentalOfferBase { 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/levels/LevelsHandler.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.levels; 2 | 3 | import me.angeschossen.lands.api.levels.requirement.CachedRequirement; 4 | import org.bukkit.configuration.ConfigurationSection; 5 | import org.jetbrains.annotations.NotNull; 6 | import org.jetbrains.annotations.Nullable; 7 | 8 | import java.util.List; 9 | import java.util.Map; 10 | 11 | /** 12 | * Used to handle levels and their progression. 13 | */ 14 | public interface LevelsHandler { 15 | /** 16 | * Get all levels that can be applied to lands ({@link me.angeschossen.lands.api.land.Land}). 17 | * @return collection of levels that can be applied to lands 18 | */ 19 | @NotNull List getLandLevels(); 20 | 21 | /** 22 | * Register a cached requirement that affects lands 23 | * @param requirement the cached requirement 24 | */ 25 | void registerCachedLandRequirement(@NotNull CachedRequirement requirement); 26 | 27 | /** 28 | * Check if there's a cached requirement ({@link CachedRequirement}) with that name that affects lands. 29 | * @param name unique name 30 | * @return true, if there's an cached requirement with that name, that affects lands 31 | */ 32 | boolean isCachedLandRequirement(@NotNull String name); 33 | 34 | /** 35 | * Check if there's a cached requirement ({@link CachedRequirement}) with that name that affects nations. 36 | * @param name unique name 37 | * @return true, if there's an cached requirement with that name, that affects nations 38 | */ 39 | boolean isCachedNationRequirement(@NotNull String name); 40 | 41 | /** 42 | * Register a cached requirement that affects nations 43 | * @param requirement the cached requirement 44 | */ 45 | void registerCachedNationRequirement(@NotNull CachedRequirement requirement); 46 | 47 | /** 48 | * Get all levels that can be applied to nations ({@link me.angeschossen.lands.api.nation.Nation}). 49 | * @return collection of levels that can be applied to nations 50 | */ 51 | @NotNull List getNationLevels(); 52 | 53 | /** 54 | * Get the land configuration section from the "levels.yml" configuration file. 55 | * @return land level configuration section 56 | */ 57 | @Nullable Map getLandSection(); 58 | 59 | /** 60 | * Get the nation configuration section from the "levels.yml" configuration file. 61 | * @return nation level configuration section 62 | */ 63 | @Nullable Map getNationSection(); 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/levels/Requirement.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.levels; 2 | 3 | import me.angeschossen.lands.api.levels.requirement.CachedRequirement; 4 | import me.angeschossen.lands.api.memberholder.MemberHolder; 5 | import org.bukkit.plugin.Plugin; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * Requirements define which requirements a land or nation needs to fullfil in order to progress to the next level. 12 | * Used for requirements that are calculated each time, a plugin requests its progress. 13 | * There is an implementation ({@link CachedRequirement}) of this class that prevents to recalculation at each request. 14 | */ 15 | public interface Requirement { 16 | /** 17 | * Get the unique name of this requirement. For display name, use {@link #getTitle()} instead. 18 | * @return unique name 19 | */ 20 | @NotNull 21 | String getName(); 22 | 23 | /** 24 | * Get the title of this requirement. 25 | * @return might include parsed color 26 | */ 27 | @NotNull 28 | String getTitle(); 29 | 30 | /** 31 | * Get the progress value. 32 | * @param memberHolder land or nation 33 | * @return example: 2 placed hoppers 34 | */ 35 | float getValue(@NotNull MemberHolder memberHolder); 36 | 37 | /** 38 | * Get the progress percentage. 39 | * @param memberHolder land or nation 40 | * @return example: 50 because 2/4 required hoppers placed 41 | */ 42 | float getProgress(@NotNull MemberHolder memberHolder); 43 | 44 | /** 45 | * Get the description of this requirement. 46 | * @return used for menus 47 | */ 48 | @NotNull 49 | List getDescription(); 50 | 51 | /** 52 | * Get the required value. 53 | * @return example: 4 hoppers placed 54 | */ 55 | float getRequired(); 56 | 57 | /** 58 | * Used for menus to display the requirement progress. 59 | * @param memberHolder land or nation 60 | * @return displays the progress 61 | */ 62 | @NotNull String getProgressDisplay(@NotNull MemberHolder memberHolder); 63 | 64 | /** 65 | * Get the plugin that provides this requirement. 66 | * @return plugin that provides this requirement 67 | */ 68 | @NotNull Plugin getPlugin(); 69 | 70 | /** 71 | * Check if this land or nation already fullfills this requirement. 72 | * @param memberHolder land or nation 73 | * @return true, if the land or nation already fullfills this requirement 74 | */ 75 | boolean matches(@NotNull MemberHolder memberHolder); 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/levels/attribute/LevelAttribute.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.levels.attribute; 2 | 3 | import com.github.angeschossen.pluginframework.api.utils.StringUtils; 4 | import me.angeschossen.lands.api.handler.APIHandler; 5 | import me.angeschossen.lands.api.memberholder.MemberHolder; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import java.util.Objects; 9 | 10 | public abstract class LevelAttribute { 11 | protected final @NotNull String description; 12 | protected final @NotNull String name; 13 | 14 | /** 15 | * Level attribute reward lands or nations when reaching a level. 16 | * @param name Name of the attribute 17 | * @param description Description of the attribute 18 | */ 19 | public LevelAttribute(@NotNull String name, @NotNull String description) { 20 | Objects.requireNonNull(name); 21 | Objects.requireNonNull(description); 22 | 23 | this.name = StringUtils.toLowerCase(name.replace(" ", "")); 24 | this.description = APIHandler.getInstance().getStringUtils().colorize(description); 25 | } 26 | 27 | /** 28 | * Check if the attribute should be applied. 29 | * @param memberHolder Land or nation 30 | * @return true, if the attribute can be applied to the land or nation. 31 | */ 32 | public abstract boolean shouldApply(@NotNull MemberHolder memberHolder); 33 | 34 | /** 35 | * Get the name of the attribute. 36 | * @return Name of the attribute 37 | */ 38 | @NotNull 39 | public final String getName() { 40 | return name; 41 | } 42 | 43 | /** 44 | * Get the description of the attribute. 45 | * @return Description of the attribute 46 | */ 47 | @NotNull 48 | public final String getAttributeDescription() { 49 | return description; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/levels/attribute/impl/ChunksAttribute.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.levels.attribute.impl; 2 | 3 | import me.angeschossen.lands.api.levels.attribute.LevelAttribute; 4 | import me.angeschossen.lands.api.memberholder.MemberHolder; 5 | import org.bukkit.ChatColor; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | /** 9 | * Rewards additional claims for /lands claim. 10 | */ 11 | public class ChunksAttribute extends LevelAttribute { 12 | private final int value; 13 | 14 | /** 15 | * Create instance. 16 | * @param name Name of the level attribute 17 | * @param description Description of the attribute 18 | * @param value Amount of chunks to reward 19 | */ 20 | public ChunksAttribute(@NotNull String name, @NotNull String description, int value) { 21 | super(name, description.replace("{value}", (value >= 0 ? ChatColor.GREEN + "+ " : ChatColor.RED + "- ") + Math.abs(value))); 22 | 23 | this.value = value; 24 | } 25 | 26 | /** 27 | * Get the amount of additional claims. 28 | * @return Additional claims 29 | */ 30 | public int getValue() { 31 | return value; 32 | } 33 | 34 | /** 35 | * Check if this attribute can be applied. 36 | * @param memberHolder Land or nation 37 | * @return Always true, since it can be applied to a land or nation 38 | */ 39 | @Override 40 | public boolean shouldApply(@NotNull MemberHolder memberHolder) { 41 | return true; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/levels/attribute/impl/EffectsAmountAttribute.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.levels.attribute.impl; 2 | 3 | import me.angeschossen.lands.api.levels.attribute.LevelAttribute; 4 | import me.angeschossen.lands.api.memberholder.MemberHolder; 5 | import me.angeschossen.lands.api.nation.Nation; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | /** 9 | * Allows a nation to have a specified amount of potion effects active at the same time. 10 | */ 11 | public class EffectsAmountAttribute extends LevelAttribute { 12 | 13 | private final int amount; 14 | 15 | /** 16 | * Create instance. 17 | * @param name Name of the effect level attribute 18 | * @param description The description 19 | * @param amount Amount of active effects 20 | */ 21 | public EffectsAmountAttribute(@NotNull String name, @NotNull String description, int amount) { 22 | super(name, description); 23 | 24 | this.amount = amount; 25 | } 26 | 27 | /** 28 | * Get the amount of potion effects, than can be active at the same time. 29 | * @return Amount of potion effects 30 | */ 31 | public int getValue() { 32 | return amount; 33 | } 34 | 35 | /** 36 | * Check if this attribute can be applied. 37 | * @param memberHolder Land or nation 38 | * @return false, if it's not a nation 39 | */ 40 | @Override 41 | public boolean shouldApply(@NotNull MemberHolder memberHolder) { 42 | return memberHolder instanceof Nation; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/levels/attribute/impl/EffectsAttribute.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.levels.attribute.impl; 2 | 3 | import com.github.angeschossen.pluginframework.api.utils.Checks; 4 | import me.angeschossen.lands.api.levels.attribute.LevelAttribute; 5 | import me.angeschossen.lands.api.memberholder.MemberHolder; 6 | import me.angeschossen.lands.api.nation.Nation; 7 | import org.bukkit.potion.PotionEffect; 8 | import org.jetbrains.annotations.NotNull; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * Rewards potion effect within a nation. 14 | * A nation can set the effect in their nation menu. 15 | */ 16 | public class EffectsAttribute extends LevelAttribute { 17 | 18 | private final List effects; 19 | 20 | /** 21 | * Create instance of this attribute. 22 | * @param name name of the attribute 23 | * @param description description of the attribute 24 | * @param effects effects that this attribute unlocks 25 | */ 26 | public EffectsAttribute(@NotNull String name, @NotNull String description,@NotNull List effects) { 27 | super(name, description); 28 | 29 | Checks.requireNonNull(effects, "effectd"); 30 | this.effects = effects; 31 | } 32 | 33 | /** 34 | * Get collection of effects that are unlocked by this attribute. 35 | * @return collection of unlocked effects 36 | */ 37 | public List getEffects() { 38 | return effects; 39 | } 40 | 41 | /** 42 | * Check if this attribute should be applied. 43 | * @param memberHolder Land or nation 44 | * @return true, if this memberHolde is a nation 45 | */ 46 | @Override 47 | public boolean shouldApply(@NotNull MemberHolder memberHolder) { 48 | return memberHolder instanceof Nation; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/levels/attribute/impl/UpkeepAttribute.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.levels.attribute.impl; 2 | 3 | import me.angeschossen.lands.api.land.Land; 4 | import me.angeschossen.lands.api.levels.attribute.LevelAttribute; 5 | import me.angeschossen.lands.api.memberholder.MemberHolder; 6 | import org.bukkit.ChatColor; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | public class UpkeepAttribute extends LevelAttribute { 10 | private final double value; 11 | 12 | /** 13 | * Create instance. 14 | * @param name Name of the effect level attribute 15 | * @param description The description 16 | * @param value Level of the effect 17 | */ 18 | public UpkeepAttribute(@NotNull String name, @NotNull String description, double value) { 19 | super(name, description.replace("{value}", (value >= 0 ? ChatColor.RED + "+ " : ChatColor.GREEN + "- ") + Math.abs(value))); 20 | 21 | this.value = value; 22 | } 23 | 24 | /** 25 | * The the upkeep modification. 26 | * @return if negative, the upkeep is reduced by this attribute 27 | */ 28 | public double getValue() { 29 | return value; 30 | } 31 | 32 | /** 33 | * Modify the upkeep of a land or nation. 34 | * @param value the current upkeep 35 | * @return modified upkeep 36 | */ 37 | public double modifyUpkeep(double value) { 38 | if (this.value == 0) { 39 | return value; 40 | } 41 | 42 | double result = value + ((value / 100) * this.value); 43 | return Math.max(0, result); // prevent minus upkeep 44 | } 45 | 46 | /** 47 | * Check if this attribute should be applied. 48 | * @param memberHolder Land or nation 49 | * @return this is only applied to lands, that aren't part of nation, or nations. 50 | */ 51 | @Override 52 | public boolean shouldApply(@NotNull MemberHolder memberHolder) { 53 | if (memberHolder instanceof Land) { 54 | return ((Land) memberHolder).getNation() == null; 55 | } else { 56 | return true; 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/levels/requirement/CachedRequirement.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.levels.requirement; 2 | 3 | import me.angeschossen.lands.api.memberholder.MemberHolder; 4 | import org.bukkit.plugin.Plugin; 5 | import org.jetbrains.annotations.NotNull; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Used for requirements, for which an update needs to be triggered. 11 | * The results of these requirements are cached, to prevent running expensive tasks over and over again. 12 | * It is the responsibility of the plugin, that provides the requirement, to update it when needed. 13 | */ 14 | public abstract class CachedRequirement extends Requirement { 15 | 16 | public CachedRequirement(@NotNull Plugin plugin, @NotNull String name, @NotNull String title, @NotNull List description, float required, @NotNull String requiredDisplay) { 17 | super(plugin, name, title, description, required, requiredDisplay); 18 | } 19 | 20 | /** 21 | * Calculate the current progress. Called whenever the requirement progress is fetched, but not cached yet. 22 | * @param memberHolder the land or nation 23 | * @return the calculated progress 24 | */ 25 | public abstract float retrieveValue(@NotNull MemberHolder memberHolder); 26 | 27 | /** 28 | * Get the progress value. If the progress isn't cached, this will call {@link #retrieveValue(MemberHolder)}. 29 | * @param memberHolder the land or nation 30 | * @return The cached or newly calculated progress. Example: 2 placed hoppers 31 | */ 32 | @Override 33 | public final float getValue(@NotNull MemberHolder memberHolder) { 34 | if (!memberHolder.isRequirementCached(name)) { 35 | float val = retrieveValue(memberHolder); 36 | memberHolder.updateRequirementCache(name, val); 37 | return val; 38 | } else { 39 | return memberHolder.getCachedRequirement(name); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/memberholder/CMDTarget.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.memberholder; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import java.util.Objects; 6 | 7 | public interface CMDTarget { 8 | /** 9 | * Replaces spaces with an underscore to make names useable as command parameters. 10 | * @param in The input 11 | * @return The name with spaces replaced with underscores 12 | */ 13 | static String parseCMDName(@NotNull String in) { 14 | Objects.requireNonNull(in, "input can't be null"); 15 | return in.replace(' ', '_'); 16 | } 17 | 18 | /** 19 | * Get the command parameter name. 20 | * @return Name that is used in command parameters. 21 | */ 22 | @NotNull 23 | String getCMDName(); 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/memberholder/HolderType.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.memberholder; 2 | 3 | public enum HolderType { 4 | /** 5 | * A land. See {@link me.angeschossen.lands.api.land.Land} 6 | */ 7 | LAND, 8 | /** 9 | * A nation. See {@link me.angeschossen.lands.api.nation.Nation} 10 | */ 11 | NATION 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/membershiprequest/LandMemberShipRequest.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.membershiprequest; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import java.util.UUID; 6 | 7 | public interface LandMemberShipRequest { 8 | 9 | /** 10 | * Get the player's UUID that requested membership in the land. 11 | * @return UUID of the requester 12 | */ 13 | @NotNull 14 | UUID getPlayerUUID(); 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/membershiprequest/MemberShipRequest.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.membershiprequest; 2 | 3 | import java.sql.Timestamp; 4 | 5 | public interface MemberShipRequest { 6 | /** 7 | * Get the time when this request was sent. 8 | * 9 | * @return Time when this request was sent 10 | */ 11 | Timestamp getTime(); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/membershiprequest/NationMemberShipRequest.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.membershiprequest; 2 | 3 | import me.angeschossen.lands.api.land.Land; 4 | import org.jetbrains.annotations.NotNull; 5 | 6 | public interface NationMemberShipRequest { 7 | /** 8 | * Get the land that requested membership in the nation. 9 | * @return Land that requested membership 10 | */ 11 | @NotNull 12 | Land getLand(); 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/nation/invite/NationInvite.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.nation.invite; 2 | 3 | import com.github.angeschossen.pluginframework.api.holder.Changeable; 4 | import me.angeschossen.lands.api.exceptions.LandAlreadyInNationException; 5 | import me.angeschossen.lands.api.land.Land; 6 | import me.angeschossen.lands.api.nation.Nation; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | public interface NationInvite extends Changeable { 10 | 11 | /** 12 | * Get the nation that sent this invite. 13 | * 14 | * @return The sender 15 | */ 16 | @NotNull 17 | Nation getSender(); 18 | 19 | /** 20 | * Get the land that received this invite. 21 | * 22 | * @return The receiving land 23 | */ 24 | @NotNull 25 | Land getReceiver(); 26 | 27 | /** 28 | * Accept this invite. 29 | * 30 | * @return false, if the land or nation does not exist anymore 31 | * @throws LandAlreadyInNationException If the land is already part of another nation 32 | */ 33 | boolean accept() throws LandAlreadyInNationException; 34 | 35 | /** 36 | * Deny this invite. 37 | */ 38 | void deny(); 39 | 40 | /** 41 | * Revoke this invite. 42 | */ 43 | void revoke(); 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/player/OfflinePlayer.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.player; 2 | 3 | import me.angeschossen.lands.api.land.Land; 4 | import org.jetbrains.annotations.NotNull; 5 | import org.jetbrains.annotations.Nullable; 6 | 7 | import java.util.Collection; 8 | import java.util.UUID; 9 | 10 | /** 11 | * Data for offline players. 12 | */ 13 | public interface OfflinePlayer { 14 | 15 | /** 16 | * Get the last known name. 17 | * 18 | * @return might not be up to date with the player's current name. Is null, if no data about this player in the database. 19 | */ 20 | @Nullable 21 | String getName(); 22 | 23 | /** 24 | * Get a players /lands edit land. Commands are executed for this land. 25 | * 26 | * @return The current /lands edit land 27 | */ 28 | @Nullable 29 | Land getEditLand(); 30 | 31 | /** 32 | * Get all lands the player owns or is a member of. 33 | * 34 | * @return All lands 35 | */ 36 | @NotNull 37 | Collection getLands(); 38 | 39 | /** 40 | * Get the number of lands (own lands and where the player is trusted). 41 | * 42 | * @return 0, if the player isn't part of any land 43 | */ 44 | int getSize(); 45 | 46 | /** 47 | * Get the identifier of this player. 48 | * 49 | * @return UUID of the player 50 | */ 51 | @NotNull 52 | UUID getUID(); 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/player/TrustedPlayer.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.player; 2 | 3 | import me.angeschossen.lands.api.land.Land; 4 | import org.jetbrains.annotations.NotNull; 5 | 6 | import java.util.UUID; 7 | 8 | public interface TrustedPlayer { 9 | 10 | /** 11 | * Get the amount of chunks that a land will be able to claim additionally, if 12 | * this player is part of a land. For trusted players, this amount is related to the lands.chunks.support.number permission. 13 | * If the player is the owner of the land, this amount is related to the lands.chunks.number permission 14 | * 15 | * @return Max amount of support claims 16 | */ 17 | int getSupportClaims(); 18 | 19 | /** 20 | * Is the player trusted in the whole land? 21 | * 22 | * @return true, if the player is trusted in the whole land 23 | */ 24 | boolean isTrustedWholeLand(); 25 | 26 | /** 27 | * Get the amount of areas, including the default area ({@link Land#getDefaultArea()}), in which the player is trusted. 28 | * @return Amount of trusted areas 29 | */ 30 | int getTrustedSize(); 31 | 32 | /** 33 | * Get the players identifier. 34 | * @return UUID of the player 35 | */ 36 | @NotNull 37 | UUID getUID(); 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/player/Visualization.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.player; 2 | 3 | public interface Visualization { 4 | 5 | /** 6 | * Check if this visualization stays permanently. 7 | * @return true, if it's permanent 8 | */ 9 | boolean isPermanent(); 10 | 11 | /** 12 | * Check if the visualization has another display cycle. 13 | * 14 | * @return false, if the visualization is about to stop. 15 | */ 16 | boolean hasNext(); 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/player/chat/ChatMode.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.player.chat; 2 | 3 | public enum ChatMode { 4 | /** 5 | * Equals /lands chat toggle, to permanently forward messages to the land chat. 6 | */ 7 | LAND, 8 | /** 9 | * Equals /nations chat toggle, to permanently forward messages to the nation chat. 10 | */ 11 | NATION 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/player/claiming/ClaimResult.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.player.claiming; 2 | 3 | public enum ClaimResult { 4 | /** 5 | * Claiming was successful. 6 | */ 7 | SUCCESS(false), 8 | /** 9 | * Claiming failed completely. 10 | */ 11 | FAILED(true), 12 | /** 13 | * Claiming failed partly, but the minor failure can be ignored. 14 | * This happens if for example not all chunks of an selection could be claimed. 15 | */ 16 | IGNOREABLE(false), 17 | /** 18 | * For example, if the selection is invalid or not complete. 19 | */ 20 | INVALID(true); 21 | 22 | public final boolean shouldStop; 23 | 24 | ClaimResult(boolean shouldStop) { 25 | this.shouldStop = shouldStop; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/player/combat/CombatTag.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.player.combat; 2 | 3 | import me.angeschossen.lands.api.LandsIntegration; 4 | import me.angeschossen.lands.api.handler.APIHandler; 5 | import me.angeschossen.lands.api.player.LandPlayer; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | public interface CombatTag { 9 | /** 10 | * Create an combat tag and apply it to both players. 11 | * 12 | * @param landsIntegration Your instance of {@link LandsIntegration} 13 | * @param attacker Initial attacker. Can't be the same as target. 14 | * @param target Initial target. Can't be the same as attacker. 15 | * @param duration Duration of this combat tag. If lower than 1, the combat tag won't expire and must be removed manually via {@link #remove()}. 16 | * Combat tags do not persist when leaving the server 17 | * @param showMessage If false, no message (by default bossbar) will be sent 18 | * @return CombatTag instance 19 | */ 20 | static @NotNull CombatTag of(@NotNull LandsIntegration landsIntegration, @NotNull LandPlayer attacker, LandPlayer target, long duration, boolean showMessage) { 21 | return APIHandler.getLandsIntegrationFactory().combatTagOf(landsIntegration, attacker, target, duration, showMessage); 22 | } 23 | 24 | /** 25 | * Get time until combat tag expires. 26 | * The resets at each hit. 27 | * 28 | * @return Expiration of combat tag 29 | */ 30 | long getTimeLeft(); 31 | 32 | /** 33 | * Get the initial attacker. 34 | * 35 | * @return Never null 36 | */ 37 | @NotNull 38 | LandPlayer getAttacker(); 39 | 40 | /** 41 | * Get the initial target. 42 | * 43 | * @return Never null 44 | */ 45 | @NotNull 46 | LandPlayer getTarget(); 47 | 48 | /** 49 | * Get the duration of this combat tag. 50 | * 51 | * @return Duration of the combat tag 52 | */ 53 | long getDuration(); 54 | 55 | /** 56 | * Removes this combat tag from both players. 57 | */ 58 | void remove(); 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/player/invite/Invite.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.player.invite; 2 | 3 | import com.github.angeschossen.pluginframework.api.holder.Changeable; 4 | import me.angeschossen.lands.api.land.Land; 5 | import me.angeschossen.lands.api.player.LandPlayer; 6 | import me.angeschossen.lands.api.player.invite.result.InviteResult; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | import java.util.UUID; 10 | import java.util.concurrent.CompletableFuture; 11 | 12 | public interface Invite extends Changeable { 13 | 14 | /** 15 | * Get the result of the acceptance of this invite. 16 | * @return Intent of this invite 17 | */ 18 | @NotNull 19 | InviteIntent getIntent(); 20 | 21 | /** 22 | * Get the UUID of the sender. 23 | * 24 | * @return UUID of the sender 25 | */ 26 | @NotNull 27 | UUID getSender(); 28 | 29 | /** 30 | * Get UUID of the receiver. 31 | * 32 | * @return UUID of the receiver 33 | */ 34 | @NotNull 35 | UUID getReceiver(); 36 | 37 | /** 38 | * Get sent date 39 | * 40 | * @return Date when the invite was sent 41 | */ 42 | long getTime(); 43 | 44 | /** 45 | * Accept this invite. 46 | * @param player The player that should get a response in chat about this acceptance 47 | * @return false, if the invite fails because of max members permission (lands.members.number). 48 | */ 49 | @NotNull CompletableFuture accept(@NotNull LandPlayer player); 50 | 51 | /** 52 | * Deny this invite. 53 | */ 54 | void deny(); 55 | 56 | /** 57 | * Get the land that sent the invite. 58 | * 59 | * @return Land that sent the invite 60 | */ 61 | @NotNull 62 | Land getLand(); 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/player/invite/InviteIntent.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.player.invite; 2 | 3 | public enum InviteIntent { 4 | /** 5 | * The land wants to trust a player. 6 | */ 7 | TRUST, 8 | /** 9 | * The land wants to set a new owner. 10 | */ 11 | OWNER, 12 | /** 13 | * The land wants to merge another land into theirs. 14 | */ 15 | MERGE 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/player/invite/result/InviteResult.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.player.invite.result; 2 | 3 | public interface InviteResult { 4 | boolean isSuccess(); 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/player/invite/result/MergeRequestResult.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.player.invite.result; 2 | 3 | public enum MergeRequestResult implements InviteResult{ 4 | FAILURE_MAX_CLAIMS, 5 | FAILURE_PLUGIN, 6 | FAILURE_ACCESS, 7 | FAILURE_SAME, 8 | FAILURE_ALREADY, 9 | FAILURE_WAR, 10 | FAILURE_NATION, 11 | FAILURE_FORCE_NEAR, 12 | FAILURE_COST, 13 | FAILURE_ANOTHER_ACTION, 14 | FAILURE_OWNER_CHANGED, 15 | SUCCESS; 16 | 17 | @Override 18 | public boolean isSuccess() { 19 | return this == SUCCESS; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/player/invite/result/TrustResult.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.player.invite.result; 2 | 3 | public enum TrustResult implements InviteResult{ 4 | /** 5 | * A player tried to trust himself. 6 | */ 7 | FAILURE_SELF, 8 | /** 9 | * A player isn't allowed to trust players. 10 | */ 11 | FAILURE_ACCESS, 12 | /** 13 | * The target player is already trusted. 14 | */ 15 | FAILURE_ALREADY, 16 | /** 17 | * The area has reched the maximum amount of members. 18 | * This is related to the lands.members.number permission. 19 | */ 20 | FAILURE_MAX_MEMBERS, 21 | /** 22 | * You can't trust an banned player. 23 | */ 24 | FAILURE_BANNED, 25 | /** 26 | * During war trusting players is disabled. 27 | */ 28 | FAILURE_WAR, 29 | /** 30 | * The target player has its own land and isn't allowed to be a member of a land 31 | * and a owner of their own land at the same time. This is related to the "invite-owner" option in config.yml. 32 | */ 33 | FAILURE_OWN_LAND, 34 | /** 35 | * The player reached its maximum amount of lands, they can be a member of. This is related to the 36 | * lands.lands.number permission. 37 | */ 38 | FAILURE_PLAYER_MAX_LANDS, 39 | /** 40 | * The target player is already invited. 41 | */ 42 | FAILURE_ALREADY_INVITED, 43 | /** 44 | * A 3rd party plugin cancelled the trust event ({@link me.angeschossen.lands.api.events.LandTrustPlayerEvent}). 45 | */ 46 | FAILURE_PLUGIN, 47 | /** 48 | * If the server doesn't use Luckperms for permissions, the target player must be online. 49 | * Using Luckperms maximum lands limits can be checked for offline players as well. 50 | */ 51 | FAILURE_OFFLINE, 52 | /** 53 | * The target player disabled receiving invites in their personal settings menu. 54 | */ 55 | FAILURE_PLAYER_FLAG_RECEIVE_INVITES, 56 | /** 57 | * The target player was invite successfully. 58 | * If invitis are enabled in config.yml. 59 | */ 60 | SUCCESS_INVITED, 61 | /** 62 | * The target player was trusted successfully. 63 | * If the player that trusts the target is a server admin or invites are disabled in config.yml. 64 | */ 65 | SUCCESS_TRUSTED; 66 | 67 | @Override 68 | public boolean isSuccess(){ 69 | return this == SUCCESS_INVITED || this == SUCCESS_TRUSTED; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/player/invite/type/MergeRequest.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.player.invite.type; 2 | 3 | import me.angeschossen.lands.api.player.invite.Invite; 4 | import me.angeschossen.lands.api.player.invite.result.MergeRequestResult; 5 | 6 | public interface MergeRequest extends Invite { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/player/invite/type/OwnerInvite.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.player.invite.type; 2 | 3 | import me.angeschossen.lands.api.player.invite.Invite; 4 | import me.angeschossen.lands.api.player.invite.result.TrustResult; 5 | 6 | public interface OwnerInvite extends Invite { 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/player/invite/type/TrustInvite.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.player.invite.type; 2 | 3 | import me.angeschossen.lands.api.player.invite.Invite; 4 | import me.angeschossen.lands.api.player.invite.result.TrustResult; 5 | 6 | public interface TrustInvite extends Invite { 7 | /** 8 | * Check if the player is going to be trusted in the whole land. 9 | * @return true, if the player is going to be trusted in the whole land 10 | */ 11 | boolean isWholeLand(); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/relations/Relation.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.relations; 2 | 3 | public enum Relation { 4 | /** 5 | * Both parties agreed to be allies. 6 | */ 7 | ALLY, 8 | /** 9 | * One party declared to other an enemy. 10 | */ 11 | ENEMY, 12 | /** 13 | * Both parties don't have any relation. 14 | */ 15 | NEUTRAL 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/relations/RelationRequest.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.relations; 2 | 3 | import com.github.angeschossen.pluginframework.api.holder.Changeable; 4 | import org.jetbrains.annotations.NotNull; 5 | 6 | public interface RelationRequest extends Changeable { 7 | /** 8 | * Get the result of this request. 9 | * 10 | * @return never null 11 | */ 12 | @NotNull Relation getIntent(); 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/role/RoleHolder.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.role; 2 | 3 | public interface RoleHolder { 4 | } 5 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/role/enums/EditPlayerResponse.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.role.enums; 2 | 3 | /** 4 | * Used to check if a player is allowed to edit a specific role or a player that is part of that role. 5 | */ 6 | public enum EditPlayerResponse { 7 | /** 8 | * The player is the tenant of the area. 9 | */ 10 | FAILURE_TENANT, 11 | /** 12 | * The role has a higher priority. 13 | */ 14 | FAILURE_ROLE_PRIORITY, 15 | /** 16 | * The player is able to edit the role or player that belongs to it. 17 | */ 18 | SUCCESS 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/role/system/SystemFlagStates.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.role.system; 2 | 3 | import com.github.angeschossen.pluginframework.api.utils.Checks; 4 | import me.angeschossen.lands.api.LandsIntegration; 5 | import me.angeschossen.lands.api.flags.type.RoleFlag; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import java.util.Set; 9 | 10 | public final class SystemFlagStates { 11 | private final @NotNull LandsIntegration integration; 12 | private final @NotNull Set flags; 13 | 14 | public SystemFlagStates(@NotNull LandsIntegration landsIntegration, @NotNull Set flags) { 15 | this.integration = Checks.requireNonNull(landsIntegration, "integration"); 16 | this.flags = Checks.requireNonNull(flags, "flags"); 17 | } 18 | 19 | @NotNull 20 | public LandsIntegration getIntegration() { 21 | return integration; 22 | } 23 | 24 | /** 25 | * Check if these flag states also contain a specific role flag. 26 | * 27 | * @param flag the flag to check 28 | * @return true, if this flag is included 29 | */ 30 | public boolean hasFlag(@NotNull RoleFlag flag) { 31 | return flags.contains(Checks.requireNonNull(flag, "flag")); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/sorting/SortingContext.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.sorting; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | import org.jetbrains.annotations.Nullable; 5 | 6 | import java.util.Collection; 7 | import java.util.List; 8 | 9 | public interface SortingContext { 10 | /** 11 | * Add a sorting to this sorting context. 12 | * 13 | * @param sorting The sorting 14 | * @throws IllegalStateException If the a sorting with the same ID already exists in this context 15 | */ 16 | void addSorting(@NotNull Sorting sorting) throws IllegalStateException; 17 | 18 | /** 19 | * Get the identification of this context. 20 | * 21 | * @return Identifier 22 | */ 23 | @NotNull String getId(); 24 | 25 | /** 26 | * Go through sorting modes. Useful for GUI etc. 27 | * 28 | * @param mode Current mode 29 | * @return Next mode in list 30 | */ 31 | @NotNull Sorting getNext(@Nullable Sorting mode); 32 | 33 | /** 34 | * Get sorting by its ID. 35 | * 36 | * @param id case insensitive ID of the sorting. Default sortings: balance, chunks, members, level, ratio_kd (kills/deaths in wars ratio) or ratio_wl (won/lost wars ratio) 37 | * @return null, if no sorting with this ID registered 38 | */ 39 | @Nullable Sorting getSortingModeById(@NotNull String id); 40 | 41 | /** 42 | * Get all sortings of this context. 43 | * 44 | * @return Sortings of this context 45 | */ 46 | @NotNull Collection> getSortings(); 47 | 48 | /** 49 | * Get sorting targets. 50 | * 51 | * @return All sorting targets 52 | */ 53 | @NotNull List getTargets(); 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/utils/PlayerUtils.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.utils; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import java.util.UUID; 6 | 7 | public interface PlayerUtils { 8 | 9 | /** 10 | * Getting the name of an player. The player might be offline. 11 | * @param playerUID The player 12 | * @return The name of the player 13 | */ 14 | @NotNull String getName(@NotNull UUID playerUID); 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/war/ActiveWarStats.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.war; 2 | 3 | /** 4 | * Stats during active war. 5 | */ 6 | public interface ActiveWarStats extends WarStats { 7 | /** 8 | * The current points. 9 | * 10 | * @return current points 11 | */ 12 | int getPoints(); 13 | 14 | /** 15 | * Get progress. 16 | * 17 | * @param warState the war to check for 18 | * @return progress until has points that are needed in percent 19 | */ 20 | float getProgress(WarState warState); 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/war/WarStats.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.war; 2 | 3 | import me.angeschossen.lands.api.war.captureflag.CaptureFlag; 4 | 5 | public interface WarStats { 6 | 7 | /** 8 | * Get points that weren't received by capturing a capture flag or killing enemies. 9 | * This includes positive point modification using {@link #modifyPoints(int)} and exploding or breaking an capture flag. 10 | * 11 | * @return Never negative 12 | */ 13 | int getPointsAdditional(); 14 | 15 | /** 16 | * Get total amount of points, including {@link #getPointsAdditional()}. 17 | * This also includes points received by killing enemies and capturing capture flags. 18 | * 19 | * @return Never negative 20 | */ 21 | float getPointsTotal(); 22 | 23 | /** 24 | * Get win-lost wars ratio. 25 | * 26 | * @return win-lost wars ratio 27 | */ 28 | double getWLRatio(); 29 | 30 | /** 31 | * Get amount of wars won. 32 | * 33 | * @return Amount of wars that they have won 34 | */ 35 | int getWon(); 36 | 37 | /** 38 | * Get amount of wars lost. 39 | * 40 | * @return Amount of wars that they have lost 41 | */ 42 | int getLost(); 43 | 44 | /** 45 | * Get kill-death wars ratio. 46 | * 47 | * @return kill-death ratio 48 | */ 49 | double getKDRatio(); 50 | 51 | /** 52 | * Get amount of kills. 53 | * 54 | * @return Amount of kills 55 | */ 56 | int getKills(); 57 | 58 | /** 59 | * Get amount of deaths. 60 | * 61 | * @return Amount of deaths 62 | */ 63 | int getDeaths(); 64 | 65 | /** 66 | * Modify points of the team. 67 | * 68 | * @param mod Can be positive or negative 69 | */ 70 | void modifyPoints(int mod); 71 | 72 | /** 73 | * Get amount of captures. See {@link CaptureFlag} for more information. 74 | * 75 | * @return Amount of captures 76 | */ 77 | int getCaptures(); 78 | 79 | /** 80 | * Set current kills. 81 | * 82 | * @param kills kills to set 83 | */ 84 | void setKills(int kills); 85 | 86 | /** 87 | * Set current deaths. 88 | * 89 | * @param deaths deaths to set 90 | */ 91 | void setDeaths(int deaths); 92 | 93 | /** 94 | * Set current captures of {@link CaptureFlag}. 95 | * 96 | * @param captures captures to set 97 | */ 98 | void setCaptures(int captures); 99 | } 100 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/war/declaration/MutualDeclaration.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.war.declaration; 2 | 3 | public interface MutualDeclaration extends WarDeclaration{ 4 | } 5 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/war/declaration/WarDeclaration.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.war.declaration; 2 | 3 | import me.angeschossen.lands.api.war.War; 4 | import me.angeschossen.lands.api.war.WarState; 5 | import me.angeschossen.lands.api.war.enums.WarTeam; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import java.util.concurrent.CompletableFuture; 9 | 10 | public interface WarDeclaration extends WarState { 11 | 12 | /** 13 | * Set tribute, which the surrenderer must pay to the enemy if they surrender. 14 | * 15 | * @param tribute Depending on the server's economy this can be cash, items etc. 16 | */ 17 | void setTribute(double tribute); 18 | 19 | /** 20 | * Set tribute, which the surrenderer must pay to the enemy if they surrender. 21 | * 22 | * @return Can't be negative 23 | */ 24 | double getTribute(); 25 | 26 | /** 27 | * Depending on the server's config there can be a maximum tribute. 28 | * 29 | * @param warTeam The team 30 | * @return Can't be negative 31 | */ 32 | double getMaxTribute(@NotNull WarTeam warTeam); 33 | 34 | /** 35 | * Check if the war preparation time ends soon. 36 | * Depends on the server's config. 37 | * 38 | * @return true, if the war starts in a matter of seconds 39 | */ 40 | boolean startsSoon(); 41 | 42 | /** 43 | * Forcefully start this war. 44 | * 45 | * @return The war 46 | */ 47 | CompletableFuture start(); 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/war/enums/WarResult.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.war.enums; 2 | 3 | public enum WarResult { 4 | /** 5 | * One team surrendered during the war or already in the preparation phase. 6 | */ 7 | SURRENDERED, 8 | /** 9 | * Both teams got the same amount of points and the time ran out. 10 | */ 11 | DRAW, 12 | /** 13 | * One team won. 14 | */ 15 | NORMAL 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/war/enums/WarSetting.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.war.enums; 2 | 3 | public enum WarSetting { 4 | 5 | /** 6 | * If enabled, team members can damage each other. 7 | */ 8 | FRIENDLY_FIRE(1); 9 | 10 | private final int id; 11 | private boolean enabled; 12 | 13 | WarSetting(int id) { 14 | this.id = id; 15 | } 16 | 17 | public static WarSetting getById(int id) throws IllegalArgumentException { 18 | for (WarSetting warSetting : values()) { 19 | if (warSetting.getId() == id) { 20 | return warSetting; 21 | } 22 | } 23 | 24 | throw new IllegalArgumentException("No warsetting with id " + id + " found."); 25 | } 26 | 27 | public boolean isEnabled() { 28 | return enabled; 29 | } 30 | 31 | public void setEnabled() { 32 | this.enabled = true; 33 | } 34 | 35 | public int getId() { 36 | return id; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/war/enums/WarStatus.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.war.enums; 2 | 3 | public enum WarStatus { 4 | /** 5 | * The war is in the preparation phase and hasn't started yet. This is usually the case after the declaration has been sent. 6 | */ 7 | PREPARATION, 8 | /** 9 | * The war is in the active phase. 10 | */ 11 | FIGHT 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/war/enums/WarTeam.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.war.enums; 2 | 3 | public enum WarTeam { 4 | 5 | /** 6 | * The initial attacker that sent the war declaration. 7 | */ 8 | ATTACKER, 9 | /** 10 | * The defender that received the war declaration. 11 | */ 12 | DEFENDER, 13 | /** 14 | * Not engaged in this war. 15 | */ 16 | NEUTRAL; 17 | 18 | public WarTeam getOpposite() { 19 | return this == ATTACKER ? DEFENDER : this == DEFENDER ? ATTACKER : NEUTRAL; 20 | } 21 | 22 | public void ensureIsAttackerOrDefender() { 23 | if (this != ATTACKER && this != DEFENDER) { 24 | throw new IllegalArgumentException("Must be an attacker or defender"); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/war/player/WarPlayer.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.war.player; 2 | 3 | import me.angeschossen.lands.api.player.LandPlayer; 4 | import org.bukkit.scoreboard.Scoreboard; 5 | import org.jetbrains.annotations.NotNull; 6 | import org.jetbrains.annotations.Nullable; 7 | 8 | /** 9 | * Holds war specific data during war for players. 10 | */ 11 | public interface WarPlayer { 12 | /** 13 | * Get the player. 14 | * 15 | * @return player interface 16 | */ 17 | @NotNull 18 | LandPlayer getLandPlayer(); 19 | 20 | /** 21 | * Set the scoreboard for this player 22 | * 23 | * @param scoreboard if null, removes scoreboard 24 | */ 25 | void setScoreboard(@Nullable Scoreboard scoreboard); 26 | 27 | /** 28 | * Get the current set scoreboard 29 | * 30 | * @return current set scoreboard 31 | */ 32 | @Nullable 33 | Scoreboard getScoreboard(); 34 | 35 | /** 36 | * Close their current war menu and set the scoreboard to the parameter. 37 | * 38 | * @param main the scoreboard to set - this will remove the current scoreboard for the nametags 39 | */ 40 | void removeMenuAndScoreboard(@Nullable Scoreboard main); 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/me/angeschossen/lands/api/war/storage/WarHandler.java: -------------------------------------------------------------------------------- 1 | package me.angeschossen.lands.api.war.storage; 2 | 3 | import me.angeschossen.lands.api.LandsIntegration; 4 | import me.angeschossen.lands.api.war.War; 5 | import org.jetbrains.annotations.NotNull; 6 | 7 | import java.util.Collection; 8 | import java.util.concurrent.CompletableFuture; 9 | 10 | /** 11 | * Can be used in combination with {@link LandsIntegration#setWarHandler(WarHandler)} to provided custom war functionality. 12 | */ 13 | public interface WarHandler { 14 | 15 | /** 16 | * Get all wars from the database. This is called sync at plugin startup to ensure all data is ready before players join, 17 | * but is never called after the server started. 18 | * 19 | * @param wars All current wars in the Lands database. You can use these instances to make your wars based on their functionality. 20 | * @return all active wars 21 | */ 22 | @NotNull 23 | Collection getAllWarsFromDatabase(Collection wars); 24 | 25 | /** 26 | * Delete a war from your database. 27 | * 28 | * @param war the war to delete 29 | * @return async completeable future 30 | */ 31 | @NotNull 32 | CompletableFuture deleteWarFromDatabase(@NotNull War war); 33 | 34 | /** 35 | * Create a new war object from the provided native war object. 36 | * 37 | * @param war native war object 38 | * @return your new war instance with custom functionality 39 | */ 40 | @NotNull 41 | War createInstance(@NotNull War war); 42 | 43 | /** 44 | * The instance of your integration. 45 | * 46 | * @return instance of your integration 47 | */ 48 | @NotNull 49 | LandsIntegration getIntegration(); 50 | } 51 | --------------------------------------------------------------------------------