mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-11-03 01:19:58 +01:00
Fix custom join messages Removes double message, adds colour codes and placeholders for the user's name.
This commit is contained in:
parent
3839b6f1f5
commit
278bb98649
@ -147,6 +147,24 @@ public class EssentialsPlayerListener implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerQuitHighest(final PlayerQuitEvent event)
|
||||
{
|
||||
if (ess.getSettings().allowSilentJoinQuit() && event.getPlayer().hasPermission("essentials.silentquit"))
|
||||
{
|
||||
event.setQuitMessage(null);
|
||||
}
|
||||
else if (ess.getSettings().isCustomQuitMessage())
|
||||
{
|
||||
final Player player = event.getPlayer();
|
||||
event.setQuitMessage(
|
||||
ess.getSettings().getCustomQuitMessage()
|
||||
.replace("{PLAYER}", player.getDisplayName())
|
||||
.replace("{USERNAME}", player.getName())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerQuit(final PlayerQuitEvent event)
|
||||
{
|
||||
@ -164,32 +182,31 @@ public class EssentialsPlayerListener implements Listener
|
||||
{
|
||||
user.getBase().getOpenInventory().getTopInventory().clear();
|
||||
}
|
||||
|
||||
if (ess.getSettings().allowSilentJoinQuit())
|
||||
{
|
||||
event.setQuitMessage(null);
|
||||
|
||||
}
|
||||
if (ess.getSettings().isCustomQuitMessage())
|
||||
{
|
||||
event.setQuitMessage(null);
|
||||
ess.broadcastMessage(ess.getSettings().getCustomQuitMessage());
|
||||
}
|
||||
user.updateActivity(false);
|
||||
user.dispose();
|
||||
}
|
||||
|
||||
@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)
|
||||
{
|
||||
if (ess.getSettings().allowSilentJoinQuit())
|
||||
{
|
||||
event.setJoinMessage(null);
|
||||
}
|
||||
if (ess.getSettings().isCustomJoinMessage())
|
||||
{
|
||||
event.setJoinMessage(null);
|
||||
}
|
||||
ess.runTaskAsynchronously(new Runnable()
|
||||
{
|
||||
@Override
|
||||
@ -202,15 +219,6 @@ public class EssentialsPlayerListener implements Listener
|
||||
|
||||
public void delayedJoin(final Player player, final String message)
|
||||
{
|
||||
if (ess.getSettings().isCustomJoinMessage())
|
||||
{
|
||||
ess.broadcastMessage(ess.getSettings().getCustomJoinMessage());
|
||||
}
|
||||
else
|
||||
{
|
||||
ess.broadcastMessage(message);
|
||||
}
|
||||
|
||||
if (!player.isOnline())
|
||||
{
|
||||
return;
|
||||
|
@ -1134,7 +1134,7 @@ public class Settings implements net.ess3.api.ISettings
|
||||
|
||||
public String _getCustomJoinMessage()
|
||||
{
|
||||
return config.getString("custom-join-message", "none");
|
||||
return ChatColor.translateAlternateColorCodes('&', config.getString("custom-join-message", "none"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1153,7 +1153,7 @@ public class Settings implements net.ess3.api.ISettings
|
||||
|
||||
public String _getCustomQuitMessage()
|
||||
{
|
||||
return config.getString("custom-quit-message", "none");
|
||||
return ChatColor.translateAlternateColorCodes('&', config.getString("custom-quit-message", "none"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -358,9 +358,11 @@ death-messages: true
|
||||
allow-silent-join-quit: false
|
||||
|
||||
# You can set a custom join message here, set to "none" to disable.
|
||||
# You may use color codes, use the {USERNAME} placeholder for the player's name.
|
||||
custom-join-message: "none"
|
||||
|
||||
# You can set a custom quit message here, set to "none" to disable.
|
||||
# You may use color codes, use the {USERNAME} placeholder for the player's name and/or the {PLAYER} placeholder for the player's display name.
|
||||
custom-quit-message: "none"
|
||||
|
||||
# Add worlds to this list, if you want to automatically disable god mode there.
|
||||
|
Loading…
Reference in New Issue
Block a user