fixed not respawning at spawnpoint on player death
This commit is contained in:
parent
a33ee357e8
commit
3f29ceb08f
@ -1,12 +0,0 @@
|
||||
package eu.mhsl.craftattack.spawn.appliances.spawnpoint;
|
||||
|
||||
import eu.mhsl.craftattack.spawn.appliance.ApplianceListener;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
public class FirstSpawnPlayerListener extends ApplianceListener<Spawnpoint> {
|
||||
@EventHandler
|
||||
public void onSpawn(PlayerJoinEvent event) {
|
||||
this.getAppliance().handlePlayerLogin(event.getPlayer());
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package eu.mhsl.craftattack.spawn.appliances.spawnpoint;
|
||||
|
||||
import eu.mhsl.craftattack.spawn.appliance.ApplianceListener;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
|
||||
public class SpawnAtSpawnpointListener extends ApplianceListener<Spawnpoint> {
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent event) {
|
||||
this.getAppliance().handlePlayerLogin(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onRespawn(PlayerRespawnEvent event) {
|
||||
if(event.isBedSpawn()) return;
|
||||
if(event.isAnchorSpawn()) return;
|
||||
event.setRespawnLocation(this.getAppliance().getSpawnPoint());
|
||||
}
|
||||
}
|
@ -38,6 +38,10 @@ public class Spawnpoint extends Appliance {
|
||||
dataContainer.set(alreadySpawned, PersistentDataType.BOOLEAN, true);
|
||||
}
|
||||
|
||||
public Location getSpawnPoint() {
|
||||
return this.spawnPoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NotNull List<ApplianceCommand<?>> commands() {
|
||||
return List.of(new SetSpawnpointCommand());
|
||||
@ -45,6 +49,6 @@ public class Spawnpoint extends Appliance {
|
||||
|
||||
@Override
|
||||
protected @NotNull List<Listener> listeners() {
|
||||
return List.of(new FirstSpawnPlayerListener());
|
||||
return List.of(new SpawnAtSpawnpointListener());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user