Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package world.bentobox.bentobox.listeners.flags.worldsettings;

import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;

import world.bentobox.bentobox.api.flags.FlagListener;
import world.bentobox.bentobox.lists.Flags;
import world.bentobox.bentobox.util.Util;

/**
* Prevents visitors at the spawn island from dying in the void.
* When the {@link Flags#SPAWN_PROTECTION} world setting is enabled,
* any player that falls into the void while at the spawn island will
* be teleported back to the spawn point instead of dying.
* Handles {@link Flags#SPAWN_PROTECTION}.
* @author tastybento
* @since 2.6.0
*/
public class SpawnProtectionListener extends FlagListener {

/**
* Prevents players at the spawn island from dying in the void.
* @param e - entity damage event
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerVoidDamage(EntityDamageEvent e) {
if (!(e.getEntity() instanceof Player p)
|| !e.getCause().equals(DamageCause.VOID)) {
return;
}
World world = Util.getWorld(p.getWorld());
if (!getIWM().inWorld(world) || !Flags.SPAWN_PROTECTION.isSetForWorld(world)) {
return;
}
// Check if the player is at the spawn island (X/Z within spawn bounds)
if (!getIslands().isAtSpawn(p.getLocation())) {
return;
}
// Cancel void damage and return the player to spawn to prevent death
e.setCancelled(true);
getIslands().spawnTeleport(world, p);

Check warning on line 45 in src/main/java/world/bentobox/bentobox/listeners/flags/worldsettings/SpawnProtectionListener.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Parameter 1 to this call is marked "@NonNull" but null could be passed.

See more on https://sonarcloud.io/project/issues?id=BentoBoxWorld_BentoBox&issues=AZzuQsD8wAnQ9xtGPNul&open=AZzuQsD8wAnQ9xtGPNul&pullRequest=2865
}
}
10 changes: 10 additions & 0 deletions src/main/java/world/bentobox/bentobox/lists/Flags.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
import world.bentobox.bentobox.listeners.flags.worldsettings.SpawnerSpawnEggsListener;
import world.bentobox.bentobox.listeners.flags.worldsettings.TreesGrowingOutsideRangeListener;
import world.bentobox.bentobox.listeners.flags.protection.RaidTriggerListener;
import world.bentobox.bentobox.listeners.flags.worldsettings.SpawnProtectionListener;
import world.bentobox.bentobox.listeners.flags.worldsettings.VisitorKeepInventoryListener;
import world.bentobox.bentobox.listeners.flags.worldsettings.WitherListener;
import world.bentobox.bentobox.managers.RanksManager;
Expand Down Expand Up @@ -666,6 +667,15 @@ private Flags() {}
*/
public static final Flag VISITOR_KEEP_INVENTORY = new Flag.Builder("VISITOR_KEEP_INVENTORY", Material.TOTEM_OF_UNDYING).listener(new VisitorKeepInventoryListener()).type(Type.WORLD_SETTING).defaultSetting(false).build();

/**
* Toggles whether visitors at the spawn island are protected from falling into the void.
* When enabled, players who fall into the void while at the spawn island will be
* teleported back to the spawn point instead of dying.
* @since 2.6.0
* @see SpawnProtectionListener
*/
public static final Flag SPAWN_PROTECTION = new Flag.Builder("SPAWN_PROTECTION", Material.BEACON).listener(new SpawnProtectionListener()).type(Type.WORLD_SETTING).defaultSetting(false).build();

// VISITOR_TRIGGER_RAID removed in 1.24.1 - replaced by RAID_TRIGGER protection flag

/**
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/locales/cs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1642,6 +1642,13 @@ protection:
&A
Členové &a Island stále ztrácejí své předměty
&a pokud zemřou na svém vlastním ostrově!
SPAWN_PROTECTION:
name: Spawn island void protection
description: |-
&a When enabled, players who fall
&a into the void at the spawn island
&a will be teleported back to the
&a spawn point instead of dying.
RAID_TRIGGER:
name: Spuštění nájezdu
description: Nastavuje minimální rank ostrova potřebný ke spuštění nájezdu
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1724,6 +1724,13 @@ protection:
&a gezähmte Haustiere nur auf die
&a Heimatinsel des Besitzers gehen
&a und sie nicht verlassen.
SPAWN_PROTECTION:
name: Spawn island void protection
description: |-
&a When enabled, players who fall
&a into the void at the spawn island
&a will be teleported back to the
&a spawn point instead of dying.
RAID_TRIGGER:
name: Raid auslösen
description: Legt den minimalen Inselrang fest, der zum Auslösen eines Raids benötigt wird
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/locales/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1695,6 +1695,13 @@ protection:
&a
&a [prefix_Island] members still lose their items
&a if they die on their own [prefix_island]!
SPAWN_PROTECTION:
name: Spawn island void protection
description: |-
&a When enabled, players who fall
&a into the void at the spawn island
&a will be teleported back to the
&a spawn point instead of dying.
RAID_TRIGGER:
name: Raid trigger
description: Sets the minimum island rank required to trigger a raid
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1684,6 +1684,13 @@ protection:
&a
&a Los miembros de [prefix_Island] aún pierden sus objetos
&a si mueren en su propio [prefix_island]!
SPAWN_PROTECTION:
name: Spawn island void protection
description: |-
&a When enabled, players who fall
&a into the void at the spawn island
&a will be teleported back to the
&a spawn point instead of dying.
RAID_TRIGGER:
name: Activador de asalto
description: Establece el rango mínimo de isla requerido para activar un asalto
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1712,6 +1712,13 @@ protection:
VISITOR_KEEP_INVENTORY:
name: Les visiteurs gardent l'inventaire au décès
description: "&a Empêcher les joueurs de perdre leur\n&a objets et expérience s'ils meurent\n&a une île dans laquelle ils sont un visiteur.\n&un\nLes membres de &a Island perdent toujours leurs objets\n&a s'ils meurent sur leur propre île\_!"
SPAWN_PROTECTION:
name: Spawn island void protection
description: |-
&a When enabled, players who fall
&a into the void at the spawn island
&a will be teleported back to the
&a spawn point instead of dying.
RAID_TRIGGER:
name: Déclencheur de raid
description: Définit le rang minimum d'île requis pour déclencher un raid
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/locales/hr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1682,6 +1682,13 @@ protection:
&a
Članovi &a Islanda i dalje gube svoje predmete
&a ako umru na vlastitom otoku!
SPAWN_PROTECTION:
name: Spawn island void protection
description: |-
&a When enabled, players who fall
&a into the void at the spawn island
&a will be teleported back to the
&a spawn point instead of dying.
RAID_TRIGGER:
name: Pokretanje racije
description: Postavlja minimalni rang otoka potreban za pokretanje racije
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/locales/hu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1741,6 +1741,13 @@ protection:
&a
&a [prefix_Island] tagjai továbbra is elveszítik tárgyaikat
&a ha a saját szigetükön halnak meg!
SPAWN_PROTECTION:
name: Spawn island void protection
description: |-
&a When enabled, players who fall
&a into the void at the spawn island
&a will be teleported back to the
&a spawn point instead of dying.
RAID_TRIGGER:
name: Rajtaütés indítása
description: Beállítja a rajtaütés indításához szükséges minimális szigetrangot
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/locales/id.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1708,6 +1708,13 @@ protection:
&A
&a Anggota pulau masih kehilangan item mereka
&a jika mereka mati di pulau mereka sendiri!
SPAWN_PROTECTION:
name: Spawn island void protection
description: |-
&a When enabled, players who fall
&a into the void at the spawn island
&a will be teleported back to the
&a spawn point instead of dying.
RAID_TRIGGER:
name: Pemicu penggerebekan
description: Menetapkan peringkat pulau minimum yang diperlukan untuk memicu penggerebekan
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/locales/it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1696,6 +1696,13 @@ protection:
&a
&a I membri di [prefix_Island] perdono comunque i loro oggetti
&a se muoiono nella propria [prefix_island]!
SPAWN_PROTECTION:
name: Spawn island void protection
description: |-
&a When enabled, players who fall
&a into the void at the spawn island
&a will be teleported back to the
&a spawn point instead of dying.
RAID_TRIGGER:
name: Attivazione incursione
description: Imposta il rango minimo dell'isola richiesto per attivare un'incursione
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/locales/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1555,6 +1555,13 @@ protection:
&a
&a アイランドのメンバーはまだアイテムを失っています
そして、彼らが自分の島で死んだ場合!
SPAWN_PROTECTION:
name: Spawn island void protection
description: |-
&a When enabled, players who fall
&a into the void at the spawn island
&a will be teleported back to the
&a spawn point instead of dying.
RAID_TRIGGER:
name: 襲撃のトリガー
description: 襲撃を引き起こすために必要な島の最低ランクを設定します
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/locales/ko.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1570,6 +1570,13 @@ protection:
&a [prefix_an-island]에서 방문자인 경우 보호합니다.
&a
&a [prefix_Island] 멤버는 자신의 [prefix_island]에서 죽으면 여전히 아이템을 잃습니다!
SPAWN_PROTECTION:
name: Spawn island void protection
description: |-
&a When enabled, players who fall
&a into the void at the spawn island
&a will be teleported back to the
&a spawn point instead of dying.
RAID_TRIGGER:
name: 레이드 트리거
description: 레이드를 시작하는 데 필요한 최소 섬 등급을 설정합니다
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/locales/lv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1706,6 +1706,13 @@ protection:
&a
&a [prefix_Island] dalībnieki joprojām zaudē savus priekšmetus
&a, ja viņi mirst savā [prefix_island]!
SPAWN_PROTECTION:
name: Spawn island void protection
description: |-
&a When enabled, players who fall
&a into the void at the spawn island
&a will be teleported back to the
&a spawn point instead of dying.
RAID_TRIGGER:
name: Iebrukuma aktivizēšana
description: Iestata minimālo salas rangu, kas nepieciešams iebrukuma aktivizēšanai
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/locales/nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1730,6 +1730,13 @@ protection:
&a
&a [prefix_Island] leden verliezen nog steeds hun items
&a als ze sterven op hun eigen [prefix_island]!
SPAWN_PROTECTION:
name: Spawn island void protection
description: |-
&a When enabled, players who fall
&a into the void at the spawn island
&a will be teleported back to the
&a spawn point instead of dying.
RAID_TRIGGER:
name: Aanval activeren
description: Stelt de minimale eilandrang in die nodig is om een aanval te activeren
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/locales/pl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1665,6 +1665,13 @@ protection:
&a Członkowie [prefix_Island] nadal tracą swoje przedmioty

&a jeśli umrą na swoim własnym [prefix_island]!
SPAWN_PROTECTION:
name: Spawn island void protection
description: |-
&a When enabled, players who fall
&a into the void at the spawn island
&a will be teleported back to the
&a spawn point instead of dying.
RAID_TRIGGER:
name: Wyzwalanie najazdu
description: Ustawia minimalny rang wyspy wymagany do wyzwolenia najazdu
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/locales/pt-BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1678,6 +1678,13 @@ protection:
&a
&a Membros de [prefix_Island] ainda perdem seus itens
&a se morrerem em seu próprio [prefix_island]!
SPAWN_PROTECTION:
name: Spawn island void protection
description: |-
&a When enabled, players who fall
&a into the void at the spawn island
&a will be teleported back to the
&a spawn point instead of dying.
RAID_TRIGGER:
name: Gatilho de invasão
description: Define o rank mínimo de ilha necessário para acionar uma invasão
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/locales/pt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1702,6 +1702,13 @@ protection:
&a
&a Membros da Ilha ainda perdem seus itens
&a se eles morrerem em sua própria ilha!
SPAWN_PROTECTION:
name: Spawn island void protection
description: |-
&a When enabled, players who fall
&a into the void at the spawn island
&a will be teleported back to the
&a spawn point instead of dying.
RAID_TRIGGER:
name: Gatilho de ataque
description: Define o nível mínimo de ilha necessário para desencadear um ataque
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/locales/ro.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1720,6 +1720,13 @@ protection:
&o
Membrii &a Island încă își pierd obiectele
&a dacă mor pe propria lor insulă!
SPAWN_PROTECTION:
name: Spawn island void protection
description: |-
&a When enabled, players who fall
&a into the void at the spawn island
&a will be teleported back to the
&a spawn point instead of dying.
RAID_TRIGGER:
name: Declanșare raid
description: Setează rangul minim al insulei necesar pentru a declanșa un raid
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/locales/ru.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1660,6 +1660,13 @@ protection:
&a
&a Участники острова все еще будут терять вещи,
&a если будут умирать на своем острове!
SPAWN_PROTECTION:
name: Spawn island void protection
description: |-
&a When enabled, players who fall
&a into the void at the spawn island
&a will be teleported back to the
&a spawn point instead of dying.
RAID_TRIGGER:
name: Запуск рейда
description: Устанавливает минимальный ранг острова для запуска рейда
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/locales/tr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1600,6 +1600,13 @@ protection:
&a
&a Island members still lose their items
&a if they die on their own island!
SPAWN_PROTECTION:
name: Spawn island void protection
description: |-
&a When enabled, players who fall
&a into the void at the spawn island
&a will be teleported back to the
&a spawn point instead of dying.
RAID_TRIGGER:
name: Baskın tetikleyici
description: Baskın tetiklemek için gereken minimum ada rütbesini belirler
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/locales/uk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1596,6 +1596,13 @@ protection:
&a
&a Учасники [prefix_Island] все одно втрачають
&a свої предмети на власному [prefix_island]!
SPAWN_PROTECTION:
name: Spawn island void protection
description: |-
&a When enabled, players who fall
&a into the void at the spawn island
&a will be teleported back to the
&a spawn point instead of dying.
RAID_TRIGGER:
name: Запуск рейду
description: Встановлює мінімальний ранг острова для запуску рейду
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/locales/vi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1658,6 +1658,13 @@ protection:
&a
&a Thành viên đảo vẫn mất đồ
&a nếu họ chết ở đảo của họ!
SPAWN_PROTECTION:
name: Spawn island void protection
description: |-
&a When enabled, players who fall
&a into the void at the spawn island
&a will be teleported back to the
&a spawn point instead of dying.
RAID_TRIGGER:
name: Kích hoạt cuộc đột kích
description: Đặt cấp độ đảo tối thiểu cần thiết để kích hoạt cuộc đột kích
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/locales/zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1530,6 +1530,13 @@ protection:
&a允许&#FAFAD2时: 玩家在他人岛屿死亡不掉落
&c禁止&#FAFAD2时: 玩家在他人岛屿死亡掉落
&4岛屿成员在自己的岛屿上死亡时仍然会掉落物品和经验
SPAWN_PROTECTION:
name: Spawn island void protection
description: |-
&a When enabled, players who fall
&a into the void at the spawn island
&a will be teleported back to the
&a spawn point instead of dying.
RAID_TRIGGER:
name: 触发袭击
description: 设置触发袭击所需的岛屿最低等级
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/locales/zh-HK.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1529,6 +1529,13 @@ protection:
&a 防止玩家失去他們的物品和
&a 經驗,只適用於他們死在了
&a 他們是游客的島嶼。
SPAWN_PROTECTION:
name: Spawn island void protection
description: |-
&a When enabled, players who fall
&a into the void at the spawn island
&a will be teleported back to the
&a spawn point instead of dying.
RAID_TRIGGER:
name: 觸發突襲
description: 設置觸發突襲所需的島嶼最低等級
Expand Down
Loading
Loading