diff --git a/pom.xml b/pom.xml
index 17faa10..22bbd98 100644
--- a/pom.xml
+++ b/pom.xml
@@ -44,15 +44,15 @@
UTF-8
UTF-8
- 1.8
+ 16
2.0.2
- 1.16.3-R0.1-SNAPSHOT
- 1.16.0
+ 1.17.1-R0.1-SNAPSHOT
+ 1.20.0
${build.version}-SNAPSHOT
- 1.8.1
+ 1.9.0
-LOCAL
@@ -138,6 +138,12 @@
${spigot.version}
provided
+
+ org.spigotmc
+ plugin-annotations
+ 1.2.3-SNAPSHOT
+ compile
+
world.bentobox
bentobox
diff --git a/src/main/java/world/bentobox/islandfly/FlyToggleCommand.java b/src/main/java/world/bentobox/islandfly/FlyToggleCommand.java
index 2e33388..87f12a9 100644
--- a/src/main/java/world/bentobox/islandfly/FlyToggleCommand.java
+++ b/src/main/java/world/bentobox/islandfly/FlyToggleCommand.java
@@ -8,18 +8,24 @@
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.bentobox.util.Util;
+import world.bentobox.islandfly.config.Settings;
/**
* This command allows to enable and disable fly mode.
*/
public class FlyToggleCommand extends CompositeCommand {
+
+
+ private Settings settings;
+
/**
* Default constructor
* @param parent Instance of CompositeCommand
*/
- public FlyToggleCommand(CompositeCommand parent) {
+ public FlyToggleCommand(CompositeCommand parent, IslandFlyAddon addon) {
super(parent, "fly");
+ this.settings = addon.getSettings();
}
@@ -47,7 +53,7 @@ public boolean canExecute(User user, String label, List args) {
// Enable fly if island is a spawn and user has permission for it
if (island.isSpawn() && user.hasPermission(this.getPermissionPrefix() + "island.flyspawn")) {
- return true;
+ return true;
}
if (!island.isAllowed(user, IslandFlyAddon.ISLAND_FLY_PROTECTION) && !user.hasPermission(this.getPermissionPrefix() + "island.flybypass")) {
@@ -57,6 +63,15 @@ public boolean canExecute(User user, String label, List args) {
}
+ if (!this.settings.isAllowCommandOutsideProtectionRange()
+ && !island.getProtectionBoundingBox().contains(user.getLocation().toVector())) {
+
+ user.sendMessage("islandfly.outside-protection-range");
+ return false;
+
+ }
+
+
return true;
}
diff --git a/src/main/java/world/bentobox/islandfly/IslandFlyAddon.java b/src/main/java/world/bentobox/islandfly/IslandFlyAddon.java
index f8cddaf..1cb5da6 100644
--- a/src/main/java/world/bentobox/islandfly/IslandFlyAddon.java
+++ b/src/main/java/world/bentobox/islandfly/IslandFlyAddon.java
@@ -84,7 +84,7 @@ public void onEnable() {
gameModeAddon.getPlayerCommand().ifPresent(
playerCommand -> {
- new FlyToggleCommand(playerCommand);
+ new FlyToggleCommand(playerCommand, this);
hooked = true;
});
diff --git a/src/main/java/world/bentobox/islandfly/IslandFlyPladdon.java b/src/main/java/world/bentobox/islandfly/IslandFlyPladdon.java
new file mode 100644
index 0000000..1f56a42
--- /dev/null
+++ b/src/main/java/world/bentobox/islandfly/IslandFlyPladdon.java
@@ -0,0 +1,31 @@
+//
+// Created by BONNe
+// Copyright - 2022
+//
+
+
+package world.bentobox.islandfly;
+
+
+import org.bukkit.plugin.java.annotation.dependency.Dependency;
+import org.bukkit.plugin.java.annotation.plugin.ApiVersion;
+import org.bukkit.plugin.java.annotation.plugin.Plugin;
+
+import world.bentobox.bentobox.api.addons.Addon;
+import world.bentobox.bentobox.api.addons.Pladdon;
+
+
+/**
+ * @author BONNe
+ */
+@Plugin(name="Pladdon", version="1.0")
+@ApiVersion(ApiVersion.Target.v1_17)
+@Dependency(value = "BentoBox")
+public class IslandFlyPladdon extends Pladdon
+{
+ @Override
+ public Addon getAddon()
+ {
+ return new IslandFlyAddon();
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/world/bentobox/islandfly/config/Settings.java b/src/main/java/world/bentobox/islandfly/config/Settings.java
index 83e0e1e..fe3bdb7 100644
--- a/src/main/java/world/bentobox/islandfly/config/Settings.java
+++ b/src/main/java/world/bentobox/islandfly/config/Settings.java
@@ -99,6 +99,30 @@ public void setDisabledGameModes(Set disabledGameModes)
{
this.disabledGameModes = disabledGameModes;
}
+
+
+
+
+ /**
+ * Method Settings#isFlyDisableOnLogout returns the flyDisableOnLogout of this object.
+ *
+ * @return the flyDisableOnLogout (type boolean) of this object.
+ */
+ public boolean isAllowCommandOutsideProtectionRange()
+ {
+ return allowCommandOutsideProtectionRange;
+ }
+
+
+ /**
+ * Method Settings#setFlyDisableOnLogout sets new value for the flyDisableOnLogout of this object.
+ * @param flyDisableOnLogout new value for this object.
+ *
+ */
+ public void setAllowCommandOutsideProtectionRange(boolean commandAllowed)
+ {
+ this.allowCommandOutsideProtectionRange = commandAllowed;
+ }
// ---------------------------------------------------------------------
@@ -125,4 +149,9 @@ public void setDisabledGameModes(Set disabledGameModes)
@ConfigComment(" - BSkyBlock")
@ConfigEntry(path = "disabled-gamemodes")
private Set disabledGameModes = new HashSet<>();
+
+ @ConfigComment("")
+ @ConfigComment("This allows the player to use the command outside the island protection range.")
+ @ConfigEntry(path = "allow-command-outside-protection-range")
+ private boolean allowCommandOutsideProtectionRange = false;
}
diff --git a/src/main/java/world/bentobox/islandfly/listeners/FlyLoginListener.java b/src/main/java/world/bentobox/islandfly/listeners/FlyLoginListener.java
index 3e0bb52..8007e84 100644
--- a/src/main/java/world/bentobox/islandfly/listeners/FlyLoginListener.java
+++ b/src/main/java/world/bentobox/islandfly/listeners/FlyLoginListener.java
@@ -64,6 +64,6 @@ public void onLogin(final PlayerJoinEvent event) {
private boolean isInAir(Player player) {
Block b = player.getLocation().getBlock();
- return player.getLocation().getBlockY() > 1 && b.getRelative(BlockFace.DOWN).isEmpty() && b.getRelative(BlockFace.DOWN, 2).isEmpty();
+ return player.getLocation().getBlockY() > (player.getWorld().getMinHeight() + 1) && b.getRelative(BlockFace.DOWN).isEmpty() && b.getRelative(BlockFace.DOWN, 2).isEmpty();
}
}
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index 696dc80..b47346b 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -15,3 +15,6 @@ logout-disable-fly: false
# disabled-gamemodes:
# - BSkyBlock
disabled-gamemodes: []
+
+#This allows the player to use the command outside the island protection range.
+allow-command-outside-protection-range: false
\ No newline at end of file
diff --git a/src/main/resources/locales/cs.yml b/src/main/resources/locales/cs.yml
index d1bd840..b497294 100644
--- a/src/main/resources/locales/cs.yml
+++ b/src/main/resources/locales/cs.yml
@@ -1,18 +1,19 @@
---
islandfly:
- cancel-disable: "&aJsi zpět, co? Palivo létání úspěšně doplněno!"
- command:
- description: povolí ti létat na tvém ostrově
- not-allowed-fly: "&c Na tomto ostrově nemáte povoleno létat"
- only-on-island: "&cMůžeš létat jen na tvém ostrově."
- disable-fly: "&cTvůj mód létání byl vypnut."
- enable-fly: "&aTvůj mód létání byl zapnut."
fly-outside-alert: "&cJsi mimo svůj ostrov, takže mód létání se vypne za &e[number]&c
sekund."
fly-turning-off-alert: "&c Už zde nesmíte létat. Vypnutí letu za &e [number] &c
sekundy."
+ disable-fly: "&cTvůj mód létání byl vypnut."
reallowed-fly: "&a Vaše moucha byla reallowed"
+ enable-fly: "&aTvůj mód létání byl zapnut."
+ cancel-disable: "&aJsi zpět, co? Palivo létání úspěšně doplněno!"
wrong-world: "&cNejsi ve správném světě herního módu"
+ outside-protection-range: "&c Mimo rozsah ochrany ostrova to nesmíte dělat"
+ command:
+ description: povolí ti létat na tvém ostrově
+ not-allowed-fly: "&c Na tomto ostrově nemáte povoleno létat"
+ only-on-island: "&cMůžeš létat jen na tvém ostrově."
protection:
flags:
ISLAND_FLY_PROTECTION:
diff --git a/src/main/resources/locales/de.yml b/src/main/resources/locales/de.yml
index 6ebe724..0f9c5d7 100644
--- a/src/main/resources/locales/de.yml
+++ b/src/main/resources/locales/de.yml
@@ -1,18 +1,19 @@
---
islandfly:
- cancel-disable: "&aDu bist zurück, huh! Flugtreibstoff erfolgreich nachgefüllt!"
- command:
- description: ermöglicht es Ihnen, auf Ihrer Insel zu fliegen
- not-allowed-fly: "&c Du darfst nicht auf dieser Insel fliegen"
- only-on-island: "&cSie können nur auf Ihrer Insel fliegen."
- disable-fly: "&cFlugmodus wurde deaktiviert."
- enable-fly: "&aFlugmodus wurde aktiviert."
fly-outside-alert: "&cSie befinden sich außerhalb Ihrer Insel, sodass der Flugmodus
in &c[number]&c Sekunden deaktiviert wird."
fly-turning-off-alert: "&c Du darfst hier nicht mehr fliegen. Ausschalten der Fliege
in &e [number] &c Sekunden."
+ disable-fly: "&cFlugmodus wurde deaktiviert."
reallowed-fly: "&a Deine Fliege wurde neu zugelassen"
+ enable-fly: "&aFlugmodus wurde aktiviert."
+ cancel-disable: "&aDu bist zurück, huh! Flugtreibstoff erfolgreich nachgefüllt!"
wrong-world: "&cSie befinden sich nicht in der richtigen Gamemode-Welt"
+ outside-protection-range: "&c Das darfst du nicht außerhalb deines Inselschutzbereichs"
+ command:
+ description: ermöglicht es Ihnen, auf Ihrer Insel zu fliegen
+ not-allowed-fly: "&c Du darfst nicht auf dieser Insel fliegen"
+ only-on-island: "&cSie können nur auf Ihrer Insel fliegen."
protection:
flags:
ISLAND_FLY_PROTECTION:
diff --git a/src/main/resources/locales/en-US.yml b/src/main/resources/locales/en-US.yml
index 063d803..e3333f3 100644
--- a/src/main/resources/locales/en-US.yml
+++ b/src/main/resources/locales/en-US.yml
@@ -6,6 +6,7 @@ islandfly:
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:
description: "allows you to fly on your island"
not-allowed-fly: "&c You are not allowed to fly on this island"
diff --git a/src/main/resources/locales/es.yml b/src/main/resources/locales/es.yml
index 8162bed..49b56b1 100644
--- a/src/main/resources/locales/es.yml
+++ b/src/main/resources/locales/es.yml
@@ -1,18 +1,20 @@
---
islandfly:
- cancel-disable: "&a Has vuelto, ¿eh? ¡Combustible a sido rellenado correctamente!"
- command:
- description: te permite volar en tu isla
- only-on-island: "&cSolo puedes volar en tu isla."
- not-allowed-fly: "&c No tienes permitido volar en esta isla"
- disable-fly: "&c Su modo de vuelo ha sido deshabilitado."
- enable-fly: "&a Su modo de vuelo ha sido habilitado."
fly-outside-alert: "&c Está fuera de su isla, por lo que el modo de vuelo se desactivará
en &e [number] &c segundos."
- wrong-world: "&cNo estás en el mundo del modo de juego correcto"
fly-turning-off-alert: "&c Ya no puedes volar aquí. Desactivar volar en &e [number]
&c segundos."
+ disable-fly: "&c Su modo de vuelo ha sido deshabilitado."
reallowed-fly: "&a Tu mosca ha sido reajustada"
+ enable-fly: "&a Su modo de vuelo ha sido habilitado."
+ cancel-disable: "&a Has vuelto, ¿eh? ¡Combustible a sido rellenado correctamente!"
+ wrong-world: "&cNo estás en el mundo del modo de juego correcto"
+ outside-protection-range: "&c No se le permite hacer eso fuera del rango de protección
+ de su isla"
+ command:
+ description: te permite volar en tu isla
+ not-allowed-fly: "&c No tienes permitido volar en esta isla"
+ only-on-island: "&cSolo puedes volar en tu isla."
protection:
flags:
ISLAND_FLY_PROTECTION:
diff --git a/src/main/resources/locales/fr.yml b/src/main/resources/locales/fr.yml
index bba8e5f..7819bbe 100644
--- a/src/main/resources/locales/fr.yml
+++ b/src/main/resources/locales/fr.yml
@@ -1,20 +1,22 @@
---
islandfly:
+ fly-outside-alert: "&cVous êtes hors de votre île, vous ne pourrez plus voler dans
+ &e[number]&c secondes."
+ fly-turning-off-alert: "&c Vous n'êtes plus autorisé à voler ici. Désactivation
+ du vol dans &e [number] &c secondes."
+ disable-fly: "&cVous ne pouvez plus voler."
+ reallowed-fly: "&a Vous pouvez de nouveau voler"
+ enable-fly: "&aVous pouvez désormais voler."
cancel-disable: "&aVous êtes de retour sur votre île ! Vous pouvez continuer à voler."
+ wrong-world: "&cVous n'êtes pas dans le bon monde de mode de jeu."
+ outside-protection-range: "&c Tu ne peux pas faire ça en dehors de la zone de protection
+ de ton île"
command:
description: vous permet de voler sur votre île
- only-on-island: "&cVous pouvez uniquement voler sur votre île."
not-allowed-fly: "&c Vous n'êtes pas autorisé à voler sur cette île"
- disable-fly: "&cVous ne pouvez plus voler."
- enable-fly: "&aVous pouvez désormais voler."
- fly-outside-alert: "&cVous êtes hors de votre île, vous ne pourrez plus voler dans
- &e[number]&c secondes."
- wrong-world: "&cVous n'êtes pas dans le bon monde de mode de jeu."
- fly-turning-off-alert: "&c Vous n'êtes plus autorisé à voler ici. Désactivation
- de fly en &e [number] &c secondes."
- reallowed-fly: "& a Votre mouche a été réaffectée"
+ only-on-island: "&cVous pouvez uniquement voler sur votre île."
protection:
flags:
ISLAND_FLY_PROTECTION:
description: "&a Toggle qui peut voler sur votre île"
- name: "&a Prévention des mouches"
+ name: "&a Interdiction du vol"
diff --git a/src/main/resources/locales/hu.yml b/src/main/resources/locales/hu.yml
index d93aa99..630b6a9 100644
--- a/src/main/resources/locales/hu.yml
+++ b/src/main/resources/locales/hu.yml
@@ -9,9 +9,10 @@ islandfly:
enable-fly: "&a Az Ön repülési módja engedélyezve van."
cancel-disable: "&a Visszatért, huh! Repülő üzemanyag feltöltése sikeresen!"
wrong-world: "&c Nem vagy a megfelelő játékmód-világban"
+ outside-protection-range: "&c Ezt nem teheted a szigetvédelmi tartományon kívül"
command:
- not-allowed-fly: "&c Ezen a szigeten nem szabad repülni"
description: lehetővé teszi repülését a szigeten
+ not-allowed-fly: "&c Ezen a szigeten nem szabad repülni"
protection:
flags:
ISLAND_FLY_PROTECTION:
diff --git a/src/main/resources/locales/id.yml b/src/main/resources/locales/id.yml
index 2abcb24..d90adce 100644
--- a/src/main/resources/locales/id.yml
+++ b/src/main/resources/locales/id.yml
@@ -9,9 +9,11 @@ islandfly:
enable-fly: "&a Mode terbang Anda telah diaktifkan."
cancel-disable: "&a Anda kembali, ya! Bahan bakar terbang berhasil diisi ulang!"
wrong-world: "&c Anda tidak berada di dunia gamemode yang tepat"
+ outside-protection-range: "&c Anda tidak diperbolehkan melakukan itu di luar jangkauan
+ perlindungan pulau Anda"
command:
- not-allowed-fly: "&c Anda tidak diizinkan terbang di pulau ini"
description: memungkinkan Anda untuk terbang di pulau Anda
+ not-allowed-fly: "&c Anda tidak diizinkan terbang di pulau ini"
protection:
flags:
ISLAND_FLY_PROTECTION:
diff --git a/src/main/resources/locales/it.yml b/src/main/resources/locales/it.yml
index b006b9e..12ff4c2 100644
--- a/src/main/resources/locales/it.yml
+++ b/src/main/resources/locales/it.yml
@@ -9,9 +9,11 @@ islandfly:
enable-fly: "&a La tua modalità di volo è stata abilitata."
cancel-disable: "&a Sei tornato, eh! Vola carburante riempito con successo!"
wrong-world: "&c Non sei nel mondo di gamemode giusto"
+ outside-protection-range: "&c Non è consentito farlo al di fuori del raggio di protezione
+ dell'isola"
command:
- not-allowed-fly: "&c Non ti è permesso volare su quest'isola"
description: ti permette di volare sulla tua isola
+ not-allowed-fly: "&c Non ti è permesso volare su quest'isola"
protection:
flags:
ISLAND_FLY_PROTECTION:
diff --git a/src/main/resources/locales/ja.yml b/src/main/resources/locales/ja.yml
index bad0242..639c225 100644
--- a/src/main/resources/locales/ja.yml
+++ b/src/main/resources/locales/ja.yml
@@ -1,16 +1,17 @@
---
islandfly:
+ fly-outside-alert: "&cあなたは島の外にいるので、&e [number]&c秒でフライモードは無効になります。"
+ fly-turning-off-alert: "&cあなたはもうここに飛ぶことはできません。 &e [number]&c秒後にフライをオフにします。"
+ disable-fly: "&cフライモードは無効になっています。"
+ reallowed-fly: "&aフライが再び許可されました"
+ enable-fly: "&aフライモードが有効になっています。"
cancel-disable: "&aあなたが戻ってきた、ハァッ!フライ燃料が正常に補充されました!"
+ wrong-world: "&cあなたは正しいゲームモードの世界にいません"
+ outside-protection-range: "&c島の保護範囲外でそれを行うことは許可されていません"
command:
description: あなたの島で飛ぶことができます
- only-on-island: "&cあなたの島でしか飛べません。"
not-allowed-fly: "&cこの島への飛行は許可されていません"
- disable-fly: "&cフライモードは無効になっています。"
- enable-fly: "&aフライモードが有効になっています。"
- fly-outside-alert: "&cあなたは島の外にいるので、&e [number]&c秒でフライモードは無効になります。"
- wrong-world: "&cあなたは正しいゲームモードの世界にいません"
- fly-turning-off-alert: "&cあなたはもうここに飛ぶことはできません。 &e [number]&c秒後にフライをオフにします。"
- reallowed-fly: "&aフライが再び許可されました"
+ only-on-island: "&cあなたの島でしか飛べません。"
protection:
flags:
ISLAND_FLY_PROTECTION:
diff --git a/src/main/resources/locales/ko.yml b/src/main/resources/locales/ko.yml
index 2ef508a..a800036 100644
--- a/src/main/resources/locales/ko.yml
+++ b/src/main/resources/locales/ko.yml
@@ -7,9 +7,10 @@ islandfly:
enable-fly: "&a 플라이 모드가 활성화되었습니다."
cancel-disable: "&a 당신은 돌아 왔습니다! 연료가 성공적으로 보충되었습니다!"
wrong-world: "&c 당신은 올바른 게임 모드 세계에 있지 않습니다"
+ outside-protection-range: "&c 당신은 당신의 섬 보호 범위 밖에서 그것을 할 수 없습니다"
command:
- not-allowed-fly: "&c 이 섬을 비행 할 수 없습니다"
description: 당신은 당신의 섬에 비행 할 수 있습니다
+ not-allowed-fly: "&c 이 섬을 비행 할 수 없습니다"
protection:
flags:
ISLAND_FLY_PROTECTION:
diff --git a/src/main/resources/locales/pl.yml b/src/main/resources/locales/pl.yml
index a7e5ed8..22fcb34 100644
--- a/src/main/resources/locales/pl.yml
+++ b/src/main/resources/locales/pl.yml
@@ -9,9 +9,11 @@ islandfly:
enable-fly: "&a Twój tryb latania został włączony."
cancel-disable: "&a Wróciłeś? Paliwo zostało uzupełnione!"
wrong-world: "&c Nie jesteś we właściwym świecie trybu gry"
+ outside-protection-range: "&c Nie możesz tego robić poza zasięgiem ochrony twojej
+ wyspy"
command:
- not-allowed-fly: "&c Nie wolno latać na tej wyspie"
description: pozwala latać na swojej wyspie
+ not-allowed-fly: "&c Nie wolno latać na tej wyspie"
protection:
flags:
ISLAND_FLY_PROTECTION:
diff --git a/src/main/resources/locales/pt.yml b/src/main/resources/locales/pt.yml
index 3d55a64..5f0f9d9 100644
--- a/src/main/resources/locales/pt.yml
+++ b/src/main/resources/locales/pt.yml
@@ -7,11 +7,13 @@ islandfly:
disable-fly: "&c Seu modo de voar foi desativado."
reallowed-fly: "&a Sua mosca foi realocada"
enable-fly: "&a Seu modo de voar foi ativado."
+ cancel-disable: Você está de volta, hein! Voar combustível reabastecido com sucesso!
wrong-world: "&c Você não está no mundo do modo de jogo certo"
+ outside-protection-range: "& c Você não tem permissão para fazer isso fora da faixa
+ de proteção da sua ilha"
command:
- not-allowed-fly: "&c Você não tem permissão para voar nesta ilha"
description: permite que você voe em sua ilha
- cancel-disable: Você está de volta, hein! Voar combustível reabastecido com sucesso!
+ not-allowed-fly: "&c Você não tem permissão para voar nesta ilha"
protection:
flags:
ISLAND_FLY_PROTECTION:
diff --git a/src/main/resources/locales/ro.yml b/src/main/resources/locales/ro.yml
index ef9c568..df584e7 100644
--- a/src/main/resources/locales/ro.yml
+++ b/src/main/resources/locales/ro.yml
@@ -9,9 +9,11 @@ islandfly:
enable-fly: "&a Modul dvs. de zbor a fost activat."
cancel-disable: "&a Te-ai întors, nu! Combustibilul zboară reumplut cu succes!"
wrong-world: "&c Nu sunteți în lumea gamemode potrivită"
+ outside-protection-range: "&c Nu aveți voie să faceți asta în afara domeniului de
+ protecție a insulei"
command:
- not-allowed-fly: "&c Nu aveți voie să zburați pe această insulă"
description: vă permite să zburați pe insula voastră
+ not-allowed-fly: "&c Nu aveți voie să zburați pe această insulă"
protection:
flags:
ISLAND_FLY_PROTECTION:
diff --git a/src/main/resources/locales/ru.yml b/src/main/resources/locales/ru.yml
index 3267b96..ad50ab0 100644
--- a/src/main/resources/locales/ru.yml
+++ b/src/main/resources/locales/ru.yml
@@ -9,9 +9,11 @@ islandfly:
enable-fly: "&a Ваш режим полета был включен."
cancel-disable: "&a Вы вернулись, да! Летное топливо успешно заправлено!"
wrong-world: "&c Вы не в правильном игровом мире"
+ outside-protection-range: "&c Вам не разрешено делать это за пределами зоны защиты
+ вашего острова."
command:
- not-allowed-fly: "&c Вы не можете летать на этом острове"
description: позволяет летать на вашем острове
+ not-allowed-fly: "&c Вы не можете летать на этом острове"
protection:
flags:
ISLAND_FLY_PROTECTION:
diff --git a/src/main/resources/locales/tr.yml b/src/main/resources/locales/tr.yml
index 26393aa..78273a1 100644
--- a/src/main/resources/locales/tr.yml
+++ b/src/main/resources/locales/tr.yml
@@ -9,9 +9,10 @@ islandfly:
enable-fly: "&a Uçuş modunuz etkinleştirildi."
cancel-disable: "&a Geri döndün, ha! Sinek yakıtı başarıyla dolduruldu!"
wrong-world: "&c Doğru oyun modu dünyasında değilsiniz"
+ outside-protection-range: "&c Bunu ada koruma alanınız dışında yapmanıza izin verilmiyor"
command:
- not-allowed-fly: "&c Bu adada uçmanıza izin verilmiyor"
description: adanda uçmana izin verir
+ not-allowed-fly: "&c Bu adada uçmanıza izin verilmiyor"
protection:
flags:
ISLAND_FLY_PROTECTION:
diff --git a/src/main/resources/locales/vi.yml b/src/main/resources/locales/vi.yml
index 1356076..30dd88a 100644
--- a/src/main/resources/locales/vi.yml
+++ b/src/main/resources/locales/vi.yml
@@ -1,19 +1,18 @@
----
islandfly:
- fly-outside-alert: "&c Bạn đang ở ngoài đảo nên chế độ bay sẽ bị tắt trong &e [number]
- &c giây."
- fly-turning-off-alert: "&c Bạn không được phép bay ở đây nữa. Tắt bay trong &e [number]
- &c giây."
- disable-fly: "&c Chế độ bay của bạn đã bị tắt."
- reallowed-fly: "&a Bạn có thể bay ngay bây giờ"
- enable-fly: "&a Chế độ bay của bạn đã được bật."
- cancel-disable: "&a Bạn đã trở lại, huh! Bay nhiên liệu nạp lại thành công!"
- wrong-world: "&c Bạn không ở trong thế giới gamemode phù hợp"
+ fly-outside-alert: "&c Bạn đã ra ngoài đảo nên chế độ bay sẽ tắt trong &e[number] &c giây."
+ fly-turning-off-alert: "&c Bạn không có quyền bay ở đây nữa. Sẽ tắt bay trong &e[number] &c giây."
+ disable-fly: "&c Chế độ bay của bạn đã tắt."
+ reallowed-fly: "&a Chế độ bay của bạn đã được cho phép"
+ enable-fly: "&a Chế độ bay của bạn đã bật."
+ cancel-disable: "&a Bạn quay lại rồi à! Nhiên liệu bay đã được nạp đầy!"
+ wrong-world: "&c Bạn ở không đúng thế giới"
+ outside-protection-range: "&c Bạn không được phép làm điều đó ngoài vùng an toàn của b"
command:
- not-allowed-fly: "&c Bạn không được phép bay trên đảo này"
- description: cho phép bạn bay trên đảo của bạn
+ description: "cho phép bay tại đảo của bạn"
+ not-allowed-fly: "&c Bạn không được phép bay tại đảo này"
+
protection:
flags:
ISLAND_FLY_PROTECTION:
- description: "&a Toggle người có thể bay trên đảo của bạn"
- name: "&a Phòng chống bay"
+ description: "&a Bật/tắt những người có thể bay"
+ name: "&a Bảo vệ khỏi người đang bay"
diff --git a/src/main/resources/locales/zh-CN.yml b/src/main/resources/locales/zh-CN.yml
index faf4c97..b8b9b2d 100644
--- a/src/main/resources/locales/zh-CN.yml
+++ b/src/main/resources/locales/zh-CN.yml
@@ -1,17 +1,18 @@
---
islandfly:
- fly-outside-alert: "&c您在岛外,因此飞行模式将在&e [number]&c秒内被禁用。"
- fly-turning-off-alert: "&c您不再被允许在这里飞行。在&e [number]&c秒内关闭飞行。"
- disable-fly: "&c您的飞行模式已被禁用。"
- reallowed-fly: "&a您的苍蝇已被放低"
- enable-fly: "&a您的飞行模式已启用。"
- cancel-disable: "&a你回来了,呵呵!飞行加油成功加油!"
- wrong-world: "&c您不在正确的游戏模式世界中"
+ fly-outside-alert: "[您已经离开岛屿]飞行模式将在 [number]秒 内被自动关闭"
+ fly-turning-off-alert: 您不再被允许在这里飞行 将在 [number]秒 内自动关闭飞行
+ disable-fly: 您的[岛屿飞行]已关闭。
+ reallowed-fly: 您被重新允许飞行
+ enable-fly: 您的[岛屿飞行]已启用。
+ cancel-disable: 您已回到岛屿
+ wrong-world: 您不在正确的游戏模式世界中
+ outside-protection-range: "&c 你不能在你的岛屿保护范围外这样做"
command:
- description: 让你飞上你的小岛
- not-allowed-fly: "&c不允许您在这个岛上飞"
+ description: '允许你在你的岛上飞行 '
+ not-allowed-fly: 您不被允许在这个岛上飞
protection:
flags:
ISLAND_FLY_PROTECTION:
- description: "&a切换谁可以在您的岛屿上飞行"
- name: "&a防蝇"
+ description: 允许谁可以在您的岛屿上飞行
+ name: 飞行警告
diff --git a/src/test/java/world/bentobox/islandfly/FlyToggleCommandTest.java b/src/test/java/world/bentobox/islandfly/FlyToggleCommandTest.java
index a30555a..3f7f4a4 100644
--- a/src/test/java/world/bentobox/islandfly/FlyToggleCommandTest.java
+++ b/src/test/java/world/bentobox/islandfly/FlyToggleCommandTest.java
@@ -20,6 +20,8 @@
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
+import org.bukkit.util.BoundingBox;
+import org.bukkit.util.Vector;
import org.eclipse.jdt.annotation.Nullable;
import org.junit.After;
import org.junit.Before;
@@ -38,6 +40,7 @@
import world.bentobox.bentobox.managers.CommandsManager;
import world.bentobox.bentobox.managers.IslandsManager;
import world.bentobox.bentobox.util.Util;
+import world.bentobox.islandfly.config.Settings;
/**
* @author tastybento
@@ -46,7 +49,7 @@
@RunWith(PowerMockRunner.class)
@PrepareForTest({Bukkit.class, BentoBox.class, Util.class})
public class FlyToggleCommandTest {
-
+
@Mock
private CompositeCommand ic;
private UUID uuid;
@@ -65,12 +68,15 @@ public class FlyToggleCommandTest {
private @Nullable Location location;
@Mock
private Island island;
-
-
+ private Settings settings;
+ @Mock
+ private BoundingBox box;
+
+
/**
* @throws java.lang.Exception
*/
-
+
@Before
public void setUp() throws Exception {
// Set up plugin
@@ -102,17 +108,27 @@ public void setUp() throws Exception {
when(user.getPermissionValue(anyString(), anyInt())).thenReturn(-1);
when(user.isPlayer()).thenReturn(true);
when(user.getLocation()).thenReturn(location);
-
+
// Util
PowerMockito.mockStatic(Util.class);
when(Util.getWorld(any())).thenReturn(world);
-
+
// Island Manager
when(plugin.getIslands()).thenReturn(im);
Optional opIsland = Optional.of(island);
when(im.getIslandAt(any())).thenReturn(opIsland);
-
- ftc = new FlyToggleCommand(ic);
+
+ // Settings
+ settings = new Settings();
+ when(addon.getSettings()).thenReturn(settings);
+
+ // Island
+ when(island.getProtectionBoundingBox()).thenReturn(box);
+ when(location.toVector()).thenReturn(new Vector(0,60,0));
+ // Locations are always inside the box for now
+ when(box.contains(any(Vector.class))).thenReturn(true);
+
+ ftc = new FlyToggleCommand(ic, addon);
}
/**
@@ -148,7 +164,7 @@ 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"));
-
+
}
/**
* Test method for {@link world.bentobox.islandfly.FlyToggleCommand#canExecute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
@@ -157,7 +173,7 @@ public void testCanExecuteWrongWorld() {
public void testCanExecuteNoIsland() {
when(im.getIslandAt(any())).thenReturn(Optional.empty());
assertFalse(ftc.canExecute(user, "fly", Collections.emptyList()));
-
+
}
/**
* Test method for {@link world.bentobox.islandfly.FlyToggleCommand#canExecute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
@@ -166,9 +182,9 @@ public void testCanExecuteNoIsland() {
public void testCanExecuteSpawn() {
when(island.isSpawn()).thenReturn(true);
when(user.hasPermission(eq("bskyblock.island.flyspawn"))).thenReturn(true);
- assertTrue(ftc.canExecute(user, "fly", Collections.emptyList()));
+ assertTrue(ftc.canExecute(user, "fly", Collections.emptyList()));
}
-
+
/**
* Test method for {@link world.bentobox.islandfly.FlyToggleCommand#canExecute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
*/
@@ -177,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(eq("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)}.
@@ -187,7 +203,7 @@ public void testCanExecuteNoFlagAllowedPermission() {
when(island.isAllowed(eq(user), any())).thenReturn(false);
when(user.hasPermission(anyString())).thenReturn(true);
assertTrue(ftc.canExecute(user, "fly", Collections.emptyList()));
- verify(user, never()).sendMessage(eq("islandfly.command.not-allowed-fly"));
+ verify(user, never()).sendMessage(anyString());
}
/**
* Test method for {@link world.bentobox.islandfly.FlyToggleCommand#canExecute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
@@ -197,13 +213,38 @@ public void testCanExecuteFlagAllowed() {
when(island.isAllowed(eq(user), any())).thenReturn(true);
when(user.hasPermission(anyString())).thenReturn(false);
assertTrue(ftc.canExecute(user, "fly", Collections.emptyList()));
- verify(user, never()).sendMessage(eq("islandfly.command.not-allowed-fly"));
+ verify(user, never()).sendMessage(anyString());
}
/**
- * Test method for {@link world.bentobox.islandfly.FlyToggleCommand#execute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
+ * Test method for {@link world.bentobox.islandfly.FlyToggleCommand#canExecute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
*/
@Test
+ public void testCanExecuteOutsideProtectionRange() {
+ when(island.isAllowed(eq(user), any())).thenReturn(true);
+ 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"));
+ }
+
+ /**
+ * Test method for {@link world.bentobox.islandfly.FlyToggleCommand#canExecute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
+ */
+ @Test
+ public void testCanExecuteOutsideProtectionRangeCommandAllowed() {
+ settings.setAllowCommandOutsideProtectionRange(true);
+ when(island.isAllowed(eq(user), any())).thenReturn(true);
+ when(user.hasPermission(anyString())).thenReturn(false);
+ when(box.contains(any(Vector.class))).thenReturn(false);
+ assertTrue(ftc.canExecute(user, "fly", Collections.emptyList()));
+ verify(user, never()).sendMessage(anyString());
+ }
+
+ /**
+ * Test method for {@link world.bentobox.islandfly.FlyToggleCommand#execute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
+ */
+ @Test //I don't know what to do here
public void testExecuteUserStringListOfStringAllowedFlight() {
when(p.getAllowFlight()).thenReturn(true);
ftc.execute(user, "fly", Collections.emptyList());