mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-22 17:18:37 +01:00
Alter config options for EssentialsX Spawn listeners (#1491)
* Add spawn-join-listener-priority setting * Make "none" an option for priority settings * Register each listener with separate priorities * Add note to spawn-join-listener priority Warns about effect on spawn-on-join
This commit is contained in:
parent
b34697040a
commit
ed5aa1f469
@ -192,6 +192,8 @@ public interface ISettings extends IConf {
|
||||
|
||||
EventPriority getRespawnPriority();
|
||||
|
||||
EventPriority getSpawnJoinPriority();
|
||||
|
||||
long getTpaAcceptCancellation();
|
||||
|
||||
long getTeleportInvulnerability();
|
||||
|
@ -961,9 +961,10 @@ public class Settings implements net.ess3.api.ISettings {
|
||||
return config.getBoolean("disable-item-pickup-while-afk", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventPriority getRespawnPriority() {
|
||||
String priority = config.getString("respawn-listener-priority", "normal").toLowerCase(Locale.ENGLISH);
|
||||
private EventPriority getPriority(String priority) {
|
||||
if ("none".equals(priority)) {
|
||||
return null;
|
||||
}
|
||||
if ("lowest".equals(priority)) {
|
||||
return EventPriority.LOWEST;
|
||||
}
|
||||
@ -982,6 +983,18 @@ public class Settings implements net.ess3.api.ISettings {
|
||||
return EventPriority.NORMAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventPriority getRespawnPriority() {
|
||||
String priority = config.getString("respawn-listener-priority", "normal").toLowerCase(Locale.ENGLISH);
|
||||
return getPriority(priority);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventPriority getSpawnJoinPriority() {
|
||||
String priority = config.getString("spawn-join-listener-priority", "normal").toLowerCase(Locale.ENGLISH);
|
||||
return getPriority(priority);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTpaAcceptCancellation() {
|
||||
return config.getLong("tpa-accept-cancellation", 120);
|
||||
|
@ -881,11 +881,18 @@ newbies:
|
||||
#kit: ''
|
||||
kit: tools
|
||||
|
||||
# What priority should we use for handling respawns?
|
||||
# Set this to none, if you want vanilla respawning behaviour.
|
||||
# Set this to lowest, if you want Multiverse to handle the respawning.
|
||||
# Set this to high, if you want EssentialsSpawn to handle the respawning.
|
||||
# Set this to highest, if you want to force EssentialsSpawn to handle the respawning.
|
||||
respawn-listener-priority: high
|
||||
|
||||
# What priority should we use for handling spawning on joining the server?
|
||||
# See respawn-listener-priority for possible values.
|
||||
# Note: changing this may impact or break spawn-on-join functionality.
|
||||
spawn-join-listener-priority: high
|
||||
|
||||
# When users die, should they respawn at their first home or bed, instead of the spawnpoint?
|
||||
respawn-at-home: false
|
||||
|
||||
|
@ -7,6 +7,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.EventException;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
@ -41,18 +42,26 @@ public class EssentialsSpawn extends JavaPlugin implements IEssentialsSpawn {
|
||||
ess.addReloadListener(spawns);
|
||||
|
||||
final EssentialsSpawnPlayerListener playerListener = new EssentialsSpawnPlayerListener(ess, spawns);
|
||||
pluginManager.registerEvent(PlayerRespawnEvent.class, playerListener, ess.getSettings().getRespawnPriority(), new EventExecutor() {
|
||||
@Override
|
||||
public void execute(final Listener ll, final Event event) throws EventException {
|
||||
((EssentialsSpawnPlayerListener) ll).onPlayerRespawn((PlayerRespawnEvent) event);
|
||||
}
|
||||
}, this);
|
||||
pluginManager.registerEvent(PlayerJoinEvent.class, playerListener, ess.getSettings().getRespawnPriority(), new EventExecutor() {
|
||||
@Override
|
||||
public void execute(final Listener ll, final Event event) throws EventException {
|
||||
((EssentialsSpawnPlayerListener) ll).onPlayerJoin((PlayerJoinEvent) event);
|
||||
}
|
||||
}, this);
|
||||
|
||||
EventPriority respawnPriority = ess.getSettings().getRespawnPriority();
|
||||
if (respawnPriority != null) {
|
||||
pluginManager.registerEvent(PlayerRespawnEvent.class, playerListener, respawnPriority, new EventExecutor() {
|
||||
@Override
|
||||
public void execute(final Listener ll, final Event event) throws EventException {
|
||||
((EssentialsSpawnPlayerListener) ll).onPlayerRespawn((PlayerRespawnEvent) event);
|
||||
}
|
||||
}, this);
|
||||
}
|
||||
|
||||
EventPriority joinPriority = ess.getSettings().getSpawnJoinPriority();
|
||||
if (joinPriority != null) {
|
||||
pluginManager.registerEvent(PlayerJoinEvent.class, playerListener, joinPriority, new EventExecutor() {
|
||||
@Override
|
||||
public void execute(final Listener ll, final Event event) throws EventException {
|
||||
((EssentialsSpawnPlayerListener) ll).onPlayerJoin((PlayerJoinEvent) event);
|
||||
}
|
||||
}, this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user