mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-13 03:40:38 +01:00
Cleanup join/quit messages.
This commit is contained in:
parent
278bb98649
commit
bac26f966c
@ -148,13 +148,15 @@ public class EssentialsPlayerListener implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onPlayerQuitHighest(final PlayerQuitEvent event)
|
public void onPlayerQuit(final PlayerQuitEvent event)
|
||||||
{
|
{
|
||||||
if (ess.getSettings().allowSilentJoinQuit() && event.getPlayer().hasPermission("essentials.silentquit"))
|
final User user = ess.getUser(event.getPlayer());
|
||||||
|
|
||||||
|
if (ess.getSettings().allowSilentJoinQuit() && user.isAuthorized("essentials.silentquit"))
|
||||||
{
|
{
|
||||||
event.setQuitMessage(null);
|
event.setQuitMessage(null);
|
||||||
}
|
}
|
||||||
else if (ess.getSettings().isCustomQuitMessage())
|
else if (ess.getSettings().isCustomQuitMessage() && event.getQuitMessage() != null)
|
||||||
{
|
{
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
event.setQuitMessage(
|
event.setQuitMessage(
|
||||||
@ -163,12 +165,7 @@ public class EssentialsPlayerListener implements Listener
|
|||||||
.replace("{USERNAME}", player.getName())
|
.replace("{USERNAME}", player.getName())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
|
||||||
public void onPlayerQuit(final PlayerQuitEvent event)
|
|
||||||
{
|
|
||||||
final User user = ess.getUser(event.getPlayer());
|
|
||||||
if (ess.getSettings().removeGodOnDisconnect() && user.isGodModeEnabled())
|
if (ess.getSettings().removeGodOnDisconnect() && user.isGodModeEnabled())
|
||||||
{
|
{
|
||||||
user.setGodModeEnabled(false);
|
user.setGodModeEnabled(false);
|
||||||
@ -187,34 +184,18 @@ public class EssentialsPlayerListener implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onPlayerJoinHighest(final PlayerJoinEvent event)
|
|
||||||
{
|
|
||||||
if(ess.getSettings().allowSilentJoinQuit() && event.getPlayer().hasPermission("essentials.silentjoin"))
|
|
||||||
{
|
|
||||||
event.setJoinMessage(null);
|
|
||||||
}
|
|
||||||
else if (ess.getSettings().isCustomJoinMessage())
|
|
||||||
{
|
|
||||||
final Player player = event.getPlayer();
|
|
||||||
event.setJoinMessage(
|
|
||||||
ess.getSettings().getCustomJoinMessage()
|
|
||||||
.replace("{PLAYER}", player.getDisplayName())
|
|
||||||
.replace("{USERNAME}", player.getName())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
|
||||||
public void onPlayerJoin(final PlayerJoinEvent event)
|
public void onPlayerJoin(final PlayerJoinEvent event)
|
||||||
{
|
{
|
||||||
|
final String joinMessage = event.getJoinMessage();
|
||||||
ess.runTaskAsynchronously(new Runnable()
|
ess.runTaskAsynchronously(new Runnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
delayedJoin(event.getPlayer(), event.getJoinMessage());
|
delayedJoin(event.getPlayer(), joinMessage);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
event.setJoinMessage(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delayedJoin(final Player player, final String message)
|
public void delayedJoin(final Player player, final String message)
|
||||||
@ -227,6 +208,7 @@ public class EssentialsPlayerListener implements Listener
|
|||||||
ess.getBackup().onPlayerJoin();
|
ess.getBackup().onPlayerJoin();
|
||||||
final User user = ess.getUser(player);
|
final User user = ess.getUser(player);
|
||||||
|
|
||||||
|
|
||||||
if (user.isNPC())
|
if (user.isNPC())
|
||||||
{
|
{
|
||||||
user.setNPC(false);
|
user.setNPC(false);
|
||||||
@ -267,6 +249,19 @@ public class EssentialsPlayerListener implements Listener
|
|||||||
user.setSleepingIgnored(true);
|
user.setSleepingIgnored(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ess.getSettings().isCustomJoinMessage())
|
||||||
|
{
|
||||||
|
ess.getServer().broadcastMessage(
|
||||||
|
ess.getSettings().getCustomJoinMessage()
|
||||||
|
.replace("{PLAYER}", player.getDisplayName())
|
||||||
|
.replace("{USERNAME}", player.getName())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if (!(ess.getSettings().allowSilentJoinQuit() && user.isAuthorized("esentials.silentjoin")))
|
||||||
|
{
|
||||||
|
ess.getServer().broadcastMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
if (!ess.getSettings().isCommandDisabled("motd") && user.isAuthorized("essentials.motd"))
|
if (!ess.getSettings().isCommandDisabled("motd") && user.isAuthorized("essentials.motd"))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -1134,7 +1134,7 @@ public class Settings implements net.ess3.api.ISettings
|
|||||||
|
|
||||||
public String _getCustomJoinMessage()
|
public String _getCustomJoinMessage()
|
||||||
{
|
{
|
||||||
return ChatColor.translateAlternateColorCodes('&', config.getString("custom-join-message", "none"));
|
return FormatUtil.replaceFormat(config.getString("custom-join-message", "none"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1153,7 +1153,7 @@ public class Settings implements net.ess3.api.ISettings
|
|||||||
|
|
||||||
public String _getCustomQuitMessage()
|
public String _getCustomQuitMessage()
|
||||||
{
|
{
|
||||||
return ChatColor.translateAlternateColorCodes('&', config.getString("custom-quit-message", "none"));
|
return FormatUtil.replaceFormat(config.getString("custom-quit-message", "none"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user