diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
new file mode 100644
index 0000000..825b18d
--- /dev/null
+++ b/.github/workflows/build.yml
@@ -0,0 +1,38 @@
+name: Build
+on:
+ push:
+ branches:
+ - develop
+ - master
+ pull_request:
+ types: [opened, synchronize, reopened]
+jobs:
+ build:
+ name: Build
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ with:
+ fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
+ - name: Set up JDK 17
+ uses: actions/setup-java@v3
+ with:
+ distribution: 'adopt'
+ java-version: 17
+ - name: Cache SonarCloud packages
+ uses: actions/cache@v3
+ with:
+ path: ~/.sonar/cache
+ key: ${{ runner.os }}-sonar
+ restore-keys: ${{ runner.os }}-sonar
+ - name: Cache Maven packages
+ uses: actions/cache@v3
+ with:
+ path: ~/.m2
+ key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
+ restore-keys: ${{ runner.os }}-m2
+ - name: Build and analyze
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
+ SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
+ run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 8c4b434..1b5f84c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -44,16 +44,20 @@
UTF-8
UTF-8
- 16
- 2.0.2
+ 17
+ 2.0.9
1.17.1-R0.1-SNAPSHOT
1.20.0
${build.version}-SNAPSHOT
- 1.10.0
+ 1.11.0
-LOCAL
+ BentoBoxWorld_Boxed
+ bentobox-world
+ https://sonarcloud.io
+
@@ -94,30 +98,6 @@
-
- sonar
-
- https://sonarcloud.io
- bentobox-world
-
-
-
-
- org.sonarsource.scanner.maven
- sonar-maven-plugin
- 3.7.0.1746
-
-
- verify
-
- sonar
-
-
-
-
-
-
-
@@ -292,33 +272,39 @@
maven-deploy-plugin
2.8.2
-
+
org.jacoco
jacoco-maven-plugin
- 0.8.7
+ 0.8.10
true
-
+
**/*Names*
- pre-unit-test
+ prepare-agent
prepare-agent
- post-unit-test
+ report
report
+
+
+ XML
+
+
+
diff --git a/src/main/java/world/bentobox/islandfly/listeners/FlyListener.java b/src/main/java/world/bentobox/islandfly/listeners/FlyListener.java
index 7cb38fa..5c6a165 100644
--- a/src/main/java/world/bentobox/islandfly/listeners/FlyListener.java
+++ b/src/main/java/world/bentobox/islandfly/listeners/FlyListener.java
@@ -6,7 +6,9 @@
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
+import org.bukkit.event.player.PlayerToggleFlightEvent;
+import world.bentobox.bentobox.api.events.island.IslandEnterEvent;
import world.bentobox.bentobox.api.events.island.IslandExitEvent;
import world.bentobox.bentobox.api.localization.TextVariables;
import world.bentobox.bentobox.api.user.User;
@@ -32,6 +34,33 @@ public FlyListener(final IslandFlyAddon addon) {
this.addon = addon;
}
+ @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
+ public void onToggleFlight(final PlayerToggleFlightEvent event) {
+ final User user = User.getInstance(event.getPlayer());
+ if (checkUser(user)) {
+ user.sendMessage("islandfly.not-allowed");
+ }
+ }
+
+ /**
+ * @param user user
+ * @return true if fly was blocked
+ */
+ private boolean checkUser(User user) {
+ String permPrefix = addon.getPlugin().getIWM().getPermissionPrefix(user.getWorld());
+ // Ignore ops
+ if (user.isOp() || user.getPlayer().getGameMode().equals(GameMode.CREATIVE)
+ || user.getPlayer().getGameMode().equals(GameMode.SPECTATOR)
+ || user.hasPermission(permPrefix + "island.flybypass")) return false;
+ return removeFly(user);
+ }
+
+ @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
+ public void onEnterIsland(final IslandEnterEvent event) {
+ final User user = User.getInstance(event.getPlayerUUID());
+ // Wait until after arriving at the island
+ Bukkit.getScheduler().runTask(this.addon.getPlugin(), () -> checkUser(user));
+ }
/**
* This method is triggered when player leaves their island.
diff --git a/src/main/resources/locales/en-US.yml b/src/main/resources/locales/en-US.yml
index e3333f3..a229f9e 100644
--- a/src/main/resources/locales/en-US.yml
+++ b/src/main/resources/locales/en-US.yml
@@ -2,6 +2,7 @@ islandfly:
fly-outside-alert: "&c You are outside your island so fly mode will be disabled in &e[number] &c seconds."
fly-turning-off-alert: "&c You are not permitted to fly here anymore. Turning fly off in &e[number] &c seconds."
disable-fly: "&c Your fly mode has been disabled."
+ not-allowed: "&c Flying is not allowed here."
reallowed-fly: "&a Your fly has been reallowed"
enable-fly: "&a Your fly mode has been enabled."
cancel-disable: "&a You are back, huh! Fly fuel successfully refilled!"