Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento committed Jun 28, 2021
2 parents 3570c52 + a96c918 commit 24c0a99
Show file tree
Hide file tree
Showing 5 changed files with 215 additions and 57 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 11
- name: Set up JDK 16
uses: actions/setup-java@v1
with:
java-version: 11
java-version: 16
- name: Cache SonarCloud packages
uses: actions/cache@v1
with:
Expand Down
110 changes: 60 additions & 50 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,28 +46,28 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<powermock.version>1.7.4</powermock.version>
<java.version>16</java.version>
<powermock.version>2.0.9</powermock.version>
<!-- More visible way how to change dependency versions -->
<spigot.version>1.16.1-R0.1-SNAPSHOT</spigot.version>
<bentobox.version>1.16.0</bentobox.version>
<spigot.version>1.17-R0.1-SNAPSHOT</spigot.version>
<bentobox.version>1.17.0</bentobox.version>
<!-- Revision variable removes warning about dynamic version -->
<revision>${build.version}-SNAPSHOT</revision>
<!-- This allows to change between versions and snapshots. -->
<build.version>3.1.1</build.version>
<build.version>3.2.0</build.version>
<build.number>-LOCAL</build.number>
<!-- Sonar Cloud -->
<sonar.projectKey>BentoBoxWorld_Border</sonar.projectKey>
<sonar.organization>bentobox-world</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
</properties>

<!-- Profiles will allow to automatically change build version. -->
<profiles>
<!-- Build profile is activated by BUILD_NUMBER variable. It replaces
0 with correct build number. -->
<!-- This profile will be used only if BUILD_NUMBER environment variable
exists. -->
<profile>
<!-- ci profile is activated if exist environment variable BUILD_NUMBER. -->
<!-- It replaces ${build.number} that is currently '-LOCAL' with
correct build number from JENKINS machine. -->
<id>ci</id>
<activation>
<property>
Expand All @@ -77,15 +77,17 @@
<properties>
<!-- Override only if necessary -->
<build.number>-b${env.BUILD_NUMBER}</build.number>
<!-- GIT_BRANCH -->
</properties>
</profile>
<!-- master profile is activated by GIT_BRANCH variable. It removes
'-SNAPSHOT' at the end of -->
<!-- ${build.version} -->
<!-- This profile will be used only if environment variable GIT_BRANCH
is origin/master. -->
<profile>
<!-- Master profile is activated if exist environment variable
GIT_BRANCH and its value is origin/master. -->
<!-- It will replace 'revision' with '${build.version}' so it
removes '-SNAPSHOT' string at the end. -->
<!-- Also, as this is release build, build number can be set
to empty string. -->
<!-- This profile will be used only if exist environment variable
GIT_BRANCH with value origin/master. -->
<id>master</id>
<activation>
<property>
Expand All @@ -96,22 +98,22 @@
<properties>
<!-- Override only if necessary -->
<revision>${build.version}</revision>
<!-- Empties build.number value -->
<!-- Empties build number variable. -->
<build.number></build.number>
</properties>
</profile>
<profile>
<id>sonar</id>
<properties>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<sonar.organization>bentobox-world</sonar.organization>
<sonar.organization>tastybento-github</sonar.organization>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.6.0.1398</version>
<version>3.4.1.1168</version>
<executions>
<execution>
<phase>verify</phase>
Expand All @@ -131,37 +133,60 @@
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots</url>
</repository>
<repository>
<id>codemc</id>
<url>https://repo.codemc.org/repository/maven-snapshots/</url>
</repository>
<repository>
<id>codemc-repo</id>
<url>https://repo.codemc.org/repository/maven-public/</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
<id>eldonexus</id>
<url>https://eldonexus.de/repository/maven-releases/</url>
</repository>
</repositories>

<dependencies>
<!-- Spigot API -->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>${spigot.version}</version>
<scope>provided</scope>
</dependency>
<!-- Mockito (Unit testing) -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.11.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>world.bentobox</groupId>
<artifactId>bentobox</artifactId>
<version>${bentobox.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.yannicklamprecht.WorldBorderAPI</groupId>
<artifactId>API</artifactId>
<version>1.165.0</version>
<groupId>com.github.yannicklamprecht.worldborderapi</groupId>
<artifactId>api</artifactId>
<version>1.170.0</version>
</dependency>
</dependencies>


<build>
<!-- By default ${revision} is ${build.version}-SNAPSHOT -->
<!-- If GIT_BRANCH variable is set to origin/master, then it will
Expand All @@ -174,6 +199,7 @@
<finalName>${project.name}-${revision}${build.number}</finalName>

<defaultGoal>clean package</defaultGoal>

<resources>
<resource>
<directory>src/main/resources</directory>
Expand All @@ -183,6 +209,9 @@
<directory>src/main/resources/locales</directory>
<targetPath>./locales</targetPath>
<filtering>false</filtering>
<includes>
<include>*.yml</include>
</includes>
</resource>
</resources>
<plugins>
Expand All @@ -191,48 +220,29 @@
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<release>${java.version}</release>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
<version>3.0.0-M5</version>
<configuration>
<argLine>
--illegal-access=permit
</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<show>public</show>
<failOnError>false</failOnError>
<additionalJOption>-Xdoclint:none</additionalJOption>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
Expand Down
22 changes: 18 additions & 4 deletions src/main/java/world/bentobox/border/listeners/ShowWorldBorder.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package world.bentobox.border.listeners;

import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.RegisteredServiceProvider;

import com.github.yannicklamprecht.worldborder.api.BorderAPI;
import com.github.yannicklamprecht.worldborder.api.WorldBorderApi;

import world.bentobox.bentobox.api.addons.Addon.State;
import world.bentobox.bentobox.api.metadata.MetaDataValue;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.database.objects.Island;
Expand All @@ -17,24 +20,35 @@
public class ShowWorldBorder implements BorderShower {

private final Border addon;
private final WorldBorderApi worldBorderApi;

public ShowWorldBorder(Border addon) {
this.addon = addon;
RegisteredServiceProvider<WorldBorderApi> worldBorderApiRegisteredServiceProvider = Bukkit.getServer().getServicesManager().getRegistration(WorldBorderApi.class);

if (worldBorderApiRegisteredServiceProvider == null) {
addon.logError("WorldBorderAPI not found");
addon.setState(State.DISABLED);
worldBorderApi = null;
return;
}

worldBorderApi = worldBorderApiRegisteredServiceProvider.getProvider();
}

@Override
public void showBorder(Player player, Island island) {
BorderAPI.getApi().resetWorldBorderToGlobal(player);
worldBorderApi.resetWorldBorderToGlobal(player);
if (addon.getSettings().getDisabledGameModes().contains(island.getGameMode())
|| !User.getInstance(player).getMetaData(BORDER_STATE_META_DATA).map(MetaDataValue::asBoolean).orElse(addon.getSettings().isShowByDefault())) {
return;
}
BorderAPI.getApi().setBorder(player, island.getProtectionRange() * 2D, island.getProtectionCenter());
worldBorderApi.setBorder(player, island.getProtectionRange() * 2D, island.getProtectionCenter());
}

@Override
public void hideBorder(User user) {
BorderAPI.getApi().resetWorldBorderToGlobal(user.getPlayer());
worldBorderApi.resetWorldBorderToGlobal(user.getPlayer());
}

}
2 changes: 1 addition & 1 deletion src/main/resources/addon.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Border
main: world.bentobox.border.Border
version: ${version}${build.number}
api-version: 1.16.0
api-version: 1.17
icon: BEDROCK

prefix: Border
Expand Down
Loading

0 comments on commit 24c0a99

Please sign in to comment.