Skip to content

Commit 328252d

Browse files
authored
Merge pull request #111 from BentoBoxWorld/develop
Version 1.11
2 parents 09a0565 + a0645c9 commit 328252d

File tree

4 files changed

+87
-33
lines changed

4 files changed

+87
-33
lines changed

.github/workflows/build.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Build
2+
on:
3+
push:
4+
branches:
5+
- develop
6+
- master
7+
pull_request:
8+
types: [opened, synchronize, reopened]
9+
jobs:
10+
build:
11+
name: Build
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
with:
16+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
17+
- name: Set up JDK 17
18+
uses: actions/setup-java@v3
19+
with:
20+
distribution: 'adopt'
21+
java-version: 17
22+
- name: Cache SonarCloud packages
23+
uses: actions/cache@v3
24+
with:
25+
path: ~/.sonar/cache
26+
key: ${{ runner.os }}-sonar
27+
restore-keys: ${{ runner.os }}-sonar
28+
- name: Cache Maven packages
29+
uses: actions/cache@v3
30+
with:
31+
path: ~/.m2
32+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
33+
restore-keys: ${{ runner.os }}-m2
34+
- name: Build and analyze
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
37+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
38+
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar

pom.xml

+19-33
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,20 @@
4444
<properties>
4545
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
4646
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
47-
<java.version>16</java.version>
48-
<powermock.version>2.0.2</powermock.version>
47+
<java.version>17</java.version>
48+
<powermock.version>2.0.9</powermock.version>
4949
<!-- More visible way how to change dependency versions -->
5050
<spigot.version>1.17.1-R0.1-SNAPSHOT</spigot.version>
5151
<bentobox.version>1.20.0</bentobox.version>
5252
<!-- Revision variable removes warning about dynamic version -->
5353
<revision>${build.version}-SNAPSHOT</revision>
5454
<!-- This allows to change between versions and snapshots. -->
55-
<build.version>1.10.0</build.version>
55+
<build.version>1.11.0</build.version>
5656
<build.number>-LOCAL</build.number>
57+
<sonar.projectKey>BentoBoxWorld_Boxed</sonar.projectKey>
58+
<sonar.organization>bentobox-world</sonar.organization>
59+
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
60+
5761
</properties>
5862

5963
<profiles>
@@ -94,30 +98,6 @@
9498
<build.number></build.number>
9599
</properties>
96100
</profile>
97-
<profile>
98-
<id>sonar</id>
99-
<properties>
100-
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
101-
<sonar.organization>bentobox-world</sonar.organization>
102-
</properties>
103-
<build>
104-
<plugins>
105-
<plugin>
106-
<groupId>org.sonarsource.scanner.maven</groupId>
107-
<artifactId>sonar-maven-plugin</artifactId>
108-
<version>3.7.0.1746</version>
109-
<executions>
110-
<execution>
111-
<phase>verify</phase>
112-
<goals>
113-
<goal>sonar</goal>
114-
</goals>
115-
</execution>
116-
</executions>
117-
</plugin>
118-
</plugins>
119-
</build>
120-
</profile>
121101
</profiles>
122102

123103
<repositories>
@@ -292,33 +272,39 @@
292272
<artifactId>maven-deploy-plugin</artifactId>
293273
<version>2.8.2</version>
294274
</plugin>
295-
<plugin>
275+
<plugin>
296276
<groupId>org.jacoco</groupId>
297277
<artifactId>jacoco-maven-plugin</artifactId>
298-
<version>0.8.7</version>
278+
<version>0.8.10</version>
299279
<configuration>
300280
<append>true</append>
301281
<excludes>
302-
<!-- This is required to prevent Jacoco from adding synthetic fields
303-
to a JavaBean class (causes errors in testing) -->
282+
<!-- This is required to prevent Jacoco from adding
283+
synthetic fields to a JavaBean class (causes errors in testing) -->
304284
<exclude>**/*Names*</exclude>
305285
</excludes>
306286
</configuration>
307287
<executions>
308288
<execution>
309-
<id>pre-unit-test</id>
289+
<id>prepare-agent</id>
310290
<goals>
311291
<goal>prepare-agent</goal>
312292
</goals>
313293
</execution>
314294
<execution>
315-
<id>post-unit-test</id>
295+
<id>report</id>
316296
<goals>
317297
<goal>report</goal>
318298
</goals>
299+
<configuration>
300+
<formats>
301+
<format>XML</format>
302+
</formats>
303+
</configuration>
319304
</execution>
320305
</executions>
321306
</plugin>
307+
322308
</plugins>
323309
</build>
324310
</project>

src/main/java/world/bentobox/islandfly/listeners/FlyListener.java

+29
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
import org.bukkit.event.EventHandler;
77
import org.bukkit.event.EventPriority;
88
import org.bukkit.event.Listener;
9+
import org.bukkit.event.player.PlayerToggleFlightEvent;
910

11+
import world.bentobox.bentobox.api.events.island.IslandEnterEvent;
1012
import world.bentobox.bentobox.api.events.island.IslandExitEvent;
1113
import world.bentobox.bentobox.api.localization.TextVariables;
1214
import world.bentobox.bentobox.api.user.User;
@@ -32,6 +34,33 @@ public FlyListener(final IslandFlyAddon addon) {
3234
this.addon = addon;
3335
}
3436

37+
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
38+
public void onToggleFlight(final PlayerToggleFlightEvent event) {
39+
final User user = User.getInstance(event.getPlayer());
40+
if (checkUser(user)) {
41+
user.sendMessage("islandfly.not-allowed");
42+
}
43+
}
44+
45+
/**
46+
* @param user user
47+
* @return true if fly was blocked
48+
*/
49+
private boolean checkUser(User user) {
50+
String permPrefix = addon.getPlugin().getIWM().getPermissionPrefix(user.getWorld());
51+
// Ignore ops
52+
if (user.isOp() || user.getPlayer().getGameMode().equals(GameMode.CREATIVE)
53+
|| user.getPlayer().getGameMode().equals(GameMode.SPECTATOR)
54+
|| user.hasPermission(permPrefix + "island.flybypass")) return false;
55+
return removeFly(user);
56+
}
57+
58+
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
59+
public void onEnterIsland(final IslandEnterEvent event) {
60+
final User user = User.getInstance(event.getPlayerUUID());
61+
// Wait until after arriving at the island
62+
Bukkit.getScheduler().runTask(this.addon.getPlugin(), () -> checkUser(user));
63+
}
3564

3665
/**
3766
* This method is triggered when player leaves their island.

src/main/resources/locales/en-US.yml

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ islandfly:
22
fly-outside-alert: "&c You are outside your island so fly mode will be disabled in &e[number] &c seconds."
33
fly-turning-off-alert: "&c You are not permitted to fly here anymore. Turning fly off in &e[number] &c seconds."
44
disable-fly: "&c Your fly mode has been disabled."
5+
not-allowed: "&c Flying is not allowed here."
56
reallowed-fly: "&a Your fly has been reallowed"
67
enable-fly: "&a Your fly mode has been enabled."
78
cancel-disable: "&a You are back, huh! Fly fuel successfully refilled!"

0 commit comments

Comments
 (0)