Add options to disable join/quit messages and custom join/quit messages

This commit is contained in:
Iaccidentally 2013-11-14 20:28:47 -05:00 committed by KHobbits
parent dde8cd8f72
commit 1ae2b094f3
4 changed files with 64 additions and 5 deletions

View File

@ -164,9 +164,15 @@ public class EssentialsPlayerListener implements Listener
{
user.getBase().getOpenInventory().getTopInventory().clear();
}
if (user.hasPermission("essentials.silentquit"))
if (ess.getSettings().isJoinQuitMessagesDisabled())
{
event.setQuitMessage(null);
}
if (!ess.getSettings().customQuitMessage().equals("none"))
{
event.setQuitMessage(null);
ess.broadcastMessage(ess.getSettings().customQuitMessage());
}
user.updateActivity(false);
user.dispose();
@ -175,7 +181,11 @@ public class EssentialsPlayerListener implements Listener
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(final PlayerJoinEvent event)
{
if (event.getPlayer().hasPermission("essentials.silentjoin"))
if (ess.getSettings().isJoinQuitMessagesDisabled())
{
event.setJoinMessage(null);
}
if (!ess.getSettings().customJoinMessage().equals("none"))
{
event.setJoinMessage(null);
}
@ -184,13 +194,21 @@ public class EssentialsPlayerListener implements Listener
@Override
public void run()
{
delayedJoin(event.getPlayer());
delayedJoin(event.getPlayer(), event.getJoinMessage());
}
});
}
public void delayedJoin(final Player player)
public void delayedJoin(final Player player, final String message)
{
if (!ess.getSettings().customJoinMessage().equals("none"))
{
ess.broadcastMessage(ess.getSettings().customJoinMessage());
}
else
{
ess.broadcastMessage(message);
}
if (!player.isOnline())
{
return;

View File

@ -195,6 +195,12 @@ public interface ISettings extends IConf
Map<String, Object> getListGroupConfig();
int getMaxNickLength();
int getMaxUserCacheCount();
boolean isJoinQuitMessagesDisabled();
String customJoinMessage();
String customQuitMessage();
}

View File

@ -519,6 +519,7 @@ public class Settings implements net.ess3.api.ISettings
economyLog = _isEcoLogEnabled();
economyLogUpdate = _isEcoLogUpdateEnabled();
economyDisabled = _isEcoDisabled();
joinQuitMessagesDisabled = _isJoinQuitMessagesDisabled();
}
private List<Integer> itemSpawnBl = new ArrayList<Integer>();
@ -1113,6 +1114,31 @@ public class Settings implements net.ess3.api.ISettings
return config.getInt("max-nick-length", 30);
}
private boolean joinQuitMessagesDisabled;
public boolean _isJoinQuitMessagesDisabled()
{
return config.getBoolean("allow-silent-join-quit");
}
@Override
public boolean isJoinQuitMessagesDisabled()
{
return joinQuitMessagesDisabled;
}
@Override
public String customJoinMessage()
{
return config.getString("custom-join-message");
}
@Override
public String customQuitMessage()
{
return config.getString("custom-quit-message");
}
// #easteregg
@Override
public int getMaxUserCacheCount()

View File

@ -353,6 +353,15 @@ cancel-afk-on-move: true
# You can disable the death messages of Minecraft here.
death-messages: true
# You can disable join and quit messages here.
allow-silent-join-quit: false
# You can set a custom join message here, set to "none" to disable.
custom-join-message: none
# You can set a custom quit message here, set to "none" to disable.
custom-quit-message: none
# Add worlds to this list, if you want to automatically disable god mode there.
no-god-in-worlds:
# - world_nether