mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-06-26 06:35:10 +02: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 getRespawnPriority();
|
||||||
|
|
||||||
|
EventPriority getSpawnJoinPriority();
|
||||||
|
|
||||||
long getTpaAcceptCancellation();
|
long getTpaAcceptCancellation();
|
||||||
|
|
||||||
long getTeleportInvulnerability();
|
long getTeleportInvulnerability();
|
||||||
|
|
|
@ -961,9 +961,10 @@ public class Settings implements net.ess3.api.ISettings {
|
||||||
return config.getBoolean("disable-item-pickup-while-afk", false);
|
return config.getBoolean("disable-item-pickup-while-afk", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private EventPriority getPriority(String priority) {
|
||||||
public EventPriority getRespawnPriority() {
|
if ("none".equals(priority)) {
|
||||||
String priority = config.getString("respawn-listener-priority", "normal").toLowerCase(Locale.ENGLISH);
|
return null;
|
||||||
|
}
|
||||||
if ("lowest".equals(priority)) {
|
if ("lowest".equals(priority)) {
|
||||||
return EventPriority.LOWEST;
|
return EventPriority.LOWEST;
|
||||||
}
|
}
|
||||||
|
@ -982,6 +983,18 @@ public class Settings implements net.ess3.api.ISettings {
|
||||||
return EventPriority.NORMAL;
|
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
|
@Override
|
||||||
public long getTpaAcceptCancellation() {
|
public long getTpaAcceptCancellation() {
|
||||||
return config.getLong("tpa-accept-cancellation", 120);
|
return config.getLong("tpa-accept-cancellation", 120);
|
||||||
|
|
|
@ -881,11 +881,18 @@ newbies:
|
||||||
#kit: ''
|
#kit: ''
|
||||||
kit: tools
|
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 lowest, if you want Multiverse to handle the respawning.
|
||||||
# Set this to high, if you want EssentialsSpawn 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.
|
# Set this to highest, if you want to force EssentialsSpawn to handle the respawning.
|
||||||
respawn-listener-priority: high
|
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?
|
# When users die, should they respawn at their first home or bed, instead of the spawnpoint?
|
||||||
respawn-at-home: false
|
respawn-at-home: false
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.EventException;
|
import org.bukkit.event.EventException;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||||
|
@ -41,19 +42,27 @@ public class EssentialsSpawn extends JavaPlugin implements IEssentialsSpawn {
|
||||||
ess.addReloadListener(spawns);
|
ess.addReloadListener(spawns);
|
||||||
|
|
||||||
final EssentialsSpawnPlayerListener playerListener = new EssentialsSpawnPlayerListener(ess, spawns);
|
final EssentialsSpawnPlayerListener playerListener = new EssentialsSpawnPlayerListener(ess, spawns);
|
||||||
pluginManager.registerEvent(PlayerRespawnEvent.class, playerListener, ess.getSettings().getRespawnPriority(), new EventExecutor() {
|
|
||||||
|
EventPriority respawnPriority = ess.getSettings().getRespawnPriority();
|
||||||
|
if (respawnPriority != null) {
|
||||||
|
pluginManager.registerEvent(PlayerRespawnEvent.class, playerListener, respawnPriority, new EventExecutor() {
|
||||||
@Override
|
@Override
|
||||||
public void execute(final Listener ll, final Event event) throws EventException {
|
public void execute(final Listener ll, final Event event) throws EventException {
|
||||||
((EssentialsSpawnPlayerListener) ll).onPlayerRespawn((PlayerRespawnEvent) event);
|
((EssentialsSpawnPlayerListener) ll).onPlayerRespawn((PlayerRespawnEvent) event);
|
||||||
}
|
}
|
||||||
}, this);
|
}, this);
|
||||||
pluginManager.registerEvent(PlayerJoinEvent.class, playerListener, ess.getSettings().getRespawnPriority(), new EventExecutor() {
|
}
|
||||||
|
|
||||||
|
EventPriority joinPriority = ess.getSettings().getSpawnJoinPriority();
|
||||||
|
if (joinPriority != null) {
|
||||||
|
pluginManager.registerEvent(PlayerJoinEvent.class, playerListener, joinPriority, new EventExecutor() {
|
||||||
@Override
|
@Override
|
||||||
public void execute(final Listener ll, final Event event) throws EventException {
|
public void execute(final Listener ll, final Event event) throws EventException {
|
||||||
((EssentialsSpawnPlayerListener) ll).onPlayerJoin((PlayerJoinEvent) event);
|
((EssentialsSpawnPlayerListener) ll).onPlayerJoin((PlayerJoinEvent) event);
|
||||||
}
|
}
|
||||||
}, this);
|
}, this);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user