Skip to content

Commit

Permalink
Release 1.11.1 (#114)
Browse files Browse the repository at this point in the history
* Version 1.11.1

* Update GitHub action to enable Sonar

* Remove code smells.

* Remove the message shown when canceling flying. Fixes #112

* BentoBox 2.0.0 API

* Update to 1.20.2 Minecraft

* Version 1.20.4
  • Loading branch information
tastybento authored Jan 14, 2024
1 parent 328252d commit 894b20c
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 50 deletions.
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ jobs:
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
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=BentoBoxWorld_IslandFly
7 changes: 3 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,16 @@
<java.version>17</java.version>
<powermock.version>2.0.9</powermock.version>
<!-- More visible way how to change dependency versions -->
<spigot.version>1.17.1-R0.1-SNAPSHOT</spigot.version>
<bentobox.version>1.20.0</bentobox.version>
<spigot.version>1.20.4-R0.1-SNAPSHOT</spigot.version>
<bentobox.version>2.0.0-SNAPSHOT</bentobox.version>
<!-- Revision variable removes warning about dynamic version -->
<revision>${build.version}-SNAPSHOT</revision>
<!-- This allows to change between versions and snapshots. -->
<build.version>1.11.0</build.version>
<build.version>1.11.1</build.version>
<build.number>-LOCAL</build.number>
<sonar.projectKey>BentoBoxWorld_Boxed</sonar.projectKey>
<sonar.organization>bentobox-world</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>

</properties>

<profiles>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ boolean removeFly(User user) {
disableFly(user);
return true;
}
if (user.getPlayer().isFlying())
user.sendMessage("islandfly.cancel-disable");
return false;
}

Expand All @@ -129,10 +127,6 @@ boolean removeFly(User user) {
disableFly(user);
return true;
}

// If false, will stay silent
if (user.getPlayer().isFlying())
user.sendMessage("islandfly.cancel-disable");
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,27 +37,26 @@ public FlyLoginListener(IslandFlyAddon addon)
* @param event Instance of PlayerQuitEvent
*/
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onLogin(final PlayerJoinEvent event) {
public void onLogin(final PlayerJoinEvent event) {
final Player player = event.getPlayer();
final User user = User.getInstance(player);
final String permPrefix = addon.getPlugin().getIWM().getPermissionPrefix(player.getWorld());
if (player.hasPermission(permPrefix + "island.fly")
&& !this.addon.getSettings().isFlyDisableOnLogout() && isInAir(player)
&& addon.getIslands().userIsOnIsland(user.getWorld(), user))
{
if (!addon.getIslands().getIslandAt(user.getLocation()).map(i -> {
if (i.isAllowed(user, IslandFlyAddon.ISLAND_FLY_PROTECTION)) {
// Enable fly
player.setFallDistance(0);
player.setAllowFlight(true);
player.setFlying(true);
user.sendMessage("islandfly.enable-fly");
return true;
}
return false;
}).orElse(false)) {
user.sendMessage("islandfly.command.not-allowed-fly");
}
&& !this.addon.getSettings().isFlyDisableOnLogout()
&& isInAir(player)
&& addon.getIslands().userIsOnIsland(user.getWorld(), user)
&& !addon.getIslands().getIslandAt(user.getLocation()).map(i -> {
if (i.isAllowed(user, IslandFlyAddon.ISLAND_FLY_PROTECTION)) {
// Enable fly
player.setFallDistance(0);
player.setAllowFlight(true);
player.setFlying(true);
user.sendMessage("islandfly.enable-fly");
return true;
}
return false;
}).orElse(false)) {
user.sendMessage("islandfly.command.not-allowed-fly");
}
}

Expand Down
1 change: 0 additions & 1 deletion src/main/resources/locales/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ islandfly:
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!"
wrong-world: "&c You are not in the right gamemode world"
outside-protection-range: "&c You are not allowed to do that outside your island protection range"
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public void testSetup() {
public void testCanExecuteWrongWorld() {
when(Util.getWorld(any())).thenReturn(mock(World.class));
assertFalse(ftc.canExecute(user, "fly", Collections.emptyList()));
verify(user).sendMessage(eq("islandfly.wrong-world"));
verify(user).sendMessage("islandfly.wrong-world");

}
/**
Expand Down Expand Up @@ -193,7 +193,7 @@ public void testCanExecuteNotAllowedFlagNoPermission() {
when(island.isAllowed(eq(user), any())).thenReturn(false);
when(user.hasPermission(anyString())).thenReturn(false);
assertFalse(ftc.canExecute(user, "fly", Collections.emptyList()));
verify(user).sendMessage(eq("islandfly.command.not-allowed-fly"));
verify(user).sendMessage("islandfly.command.not-allowed-fly");
}
/**
* Test method for {@link world.bentobox.islandfly.FlyToggleCommand#canExecute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
Expand Down Expand Up @@ -225,7 +225,7 @@ public void testCanExecuteOutsideProtectionRange() {
when(user.hasPermission(anyString())).thenReturn(false);
when(box.contains(any(Vector.class))).thenReturn(false);
assertFalse(ftc.canExecute(user, "fly", Collections.emptyList()));
verify(user).sendMessage(eq("islandfly.outside-protection-range"));
verify(user).sendMessage("islandfly.outside-protection-range");
}

/**
Expand Down
16 changes: 8 additions & 8 deletions src/test/java/world/bentobox/islandfly/IslandFlyAddonTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public class IslandFlyAddonTest {
private GameModeAddon gameMode;
@Mock
private FlagsManager fm;

@BeforeClass
public static void beforeClass() throws Exception {
// Clean up
Expand Down Expand Up @@ -100,7 +100,7 @@ public void setUp() throws Exception {
when(plugin.getAddonsManager()).thenReturn(am);
// One game mode
when(am.getGameModeAddons()).thenReturn(Collections.singletonList(gameMode));

AddonDescription desc2 = new AddonDescription.Builder("bentobox", "BSkyBlock", "1.3").description("test").authors("tasty").build();
when(gameMode.getDescription()).thenReturn(desc2);
// Addon
Expand All @@ -117,11 +117,11 @@ public void setUp() throws Exception {
Optional<CompositeCommand> opCmd = Optional.of(cmd);
when(gameMode.getPlayerCommand()).thenReturn(opCmd);
// Settings


}


/**
* @throws java.lang.Exception
*/
Expand Down Expand Up @@ -156,7 +156,7 @@ public void testOnEnable() {
verify(am).registerListener(eq(ifa), any(FlyLogoutListener.class));
verify(am).registerListener(eq(ifa), any(FlyFlagListener.class));
}

/**
* Test method for {@link world.bentobox.islandfly.IslandFlyAddon#onEnable()}.
*/
Expand All @@ -179,9 +179,9 @@ public void testOnEnableNoHook() {
public void testOnReloadHooked() {
testOnEnable();
ifa.onReload();
verify(plugin).log(eq("[island fly addon] IslandFly addon reloaded."));
verify(plugin).log("[island fly addon] IslandFly addon reloaded.");
}

/**
* Test method for {@link world.bentobox.islandfly.IslandFlyAddon#onReload()}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public void testOnExitIslandGraceTime() {
when(event.getPlayerUUID()).thenReturn(uuid);
fl.onExitIsland(event);
verify(sch).runTaskLater(eq(plugin), any(Runnable.class), eq(100L));
verify(p).sendMessage(eq("islandfly.fly-outside-alert"));
verify(p).sendMessage("islandfly.fly-outside-alert");
}

/**
Expand Down Expand Up @@ -196,7 +196,7 @@ public void testOnExitIslandGraceTimeNotFlying() {
when(event.getPlayerUUID()).thenReturn(uuid);
fl.onExitIsland(event);
verify(sch).runTaskLater(eq(plugin), any(Runnable.class), eq(100L));
verify(p, never()).sendMessage(eq("islandfly.fly-outside-alert"));
verify(p, never()).sendMessage("islandfly.fly-outside-alert");
}

/**
Expand All @@ -210,7 +210,7 @@ public void testOnExitIslandNoGraceTime() {
when(event.getPlayerUUID()).thenReturn(uuid);
fl.onExitIsland(event);
verify(sch, never()).runTaskLater(eq(plugin), any(Runnable.class), any(Long.class));
verify(p).sendMessage(eq("islandfly.disable-fly"));
verify(p).sendMessage("islandfly.disable-fly");
}

/**
Expand All @@ -225,7 +225,7 @@ public void testOnExitIslandNoGraceTimeNoPermission() {
when(event.getPlayerUUID()).thenReturn(uuid);
fl.onExitIsland(event);
verify(sch, never()).runTaskLater(eq(plugin), any(Runnable.class), any(Long.class));
verify(p, never()).sendMessage(eq("islandfly.disable-fly"));
verify(p, never()).sendMessage("islandfly.disable-fly");
}

/**
Expand All @@ -243,7 +243,7 @@ public void testOnExitIslandNoGraceTimeCreativeOrSpectator() {
when(p.getGameMode()).thenReturn(GameMode.SPECTATOR);
fl.onExitIsland(event);
verify(sch, never()).runTaskLater(eq(plugin), any(Runnable.class), any(Long.class));
verify(p, never()).sendMessage(eq("islandfly.disable-fly"));
verify(p, never()).sendMessage("islandfly.disable-fly");
}


Expand All @@ -267,7 +267,7 @@ public void testRemoveFlyUserFlyingOutsideProtectedIsland() {
assertTrue(fl.removeFly(user));
verify(p).setFlying(false);
verify(p).setAllowFlight(false);
verify(user).sendMessage(eq("islandfly.disable-fly"));
verify(user).sendMessage("islandfly.disable-fly");
}

/**
Expand All @@ -276,7 +276,6 @@ public void testRemoveFlyUserFlyingOutsideProtectedIsland() {
@Test
public void testRemoveFlyUserFlyingBackInProtectedAreaOfIsland() {
assertFalse(fl.removeFly(user));
verify(user).sendMessage(eq("islandfly.cancel-disable"));
}

/**
Expand All @@ -288,7 +287,7 @@ public void testRemoveFlyUserFlyingInOtherIslandNotAllowed() {
assertTrue(fl.removeFly(user));
verify(p).setFlying(false);
verify(p).setAllowFlight(false);
verify(user).sendMessage(eq("islandfly.disable-fly"));
verify(user).sendMessage("islandfly.disable-fly");
}

/**
Expand All @@ -310,7 +309,7 @@ public void testRemoveFlyUserFlyingInOwnProtectedIslandNotAllowed() {
assertTrue(fl.removeFly(user));
verify(p).setFlying(false);
verify(p).setAllowFlight(false);
verify(user).sendMessage(eq("islandfly.disable-fly"));
verify(user).sendMessage("islandfly.disable-fly");
}


Expand All @@ -333,7 +332,7 @@ public void testRemoveFlyUserFlyingInSpawnNotAllowed() {
assertTrue(fl.removeFly(user));
verify(p).setFlying(false);
verify(p).setAllowFlight(false);
verify(user).sendMessage(eq("islandfly.disable-fly"));
verify(user).sendMessage("islandfly.disable-fly");
}

}

0 comments on commit 894b20c

Please sign in to comment.