Cache join/quit messages.

This commit is contained in:
KHobbits 2013-12-02 02:47:39 +00:00
parent 1ae2b094f3
commit c57c791e69
5 changed files with 58 additions and 24 deletions

View file

@ -164,15 +164,16 @@ public class EssentialsPlayerListener implements Listener
{ {
user.getBase().getOpenInventory().getTopInventory().clear(); user.getBase().getOpenInventory().getTopInventory().clear();
} }
if (ess.getSettings().isJoinQuitMessagesDisabled())
if (ess.getSettings().allowSilentJoinQuit())
{ {
event.setQuitMessage(null); event.setQuitMessage(null);
} }
if (!ess.getSettings().customQuitMessage().equals("none")) if (ess.getSettings().isCustomQuitMessage())
{ {
event.setQuitMessage(null); event.setQuitMessage(null);
ess.broadcastMessage(ess.getSettings().customQuitMessage()); ess.broadcastMessage(ess.getSettings().getCustomQuitMessage());
} }
user.updateActivity(false); user.updateActivity(false);
user.dispose(); user.dispose();
@ -181,11 +182,11 @@ public class EssentialsPlayerListener implements Listener
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(final PlayerJoinEvent event) public void onPlayerJoin(final PlayerJoinEvent event)
{ {
if (ess.getSettings().isJoinQuitMessagesDisabled()) if (ess.getSettings().allowSilentJoinQuit())
{ {
event.setJoinMessage(null); event.setJoinMessage(null);
} }
if (!ess.getSettings().customJoinMessage().equals("none")) if (ess.getSettings().isCustomJoinMessage())
{ {
event.setJoinMessage(null); event.setJoinMessage(null);
} }
@ -201,14 +202,15 @@ public class EssentialsPlayerListener implements Listener
public void delayedJoin(final Player player, final String message) public void delayedJoin(final Player player, final String message)
{ {
if (!ess.getSettings().customJoinMessage().equals("none")) if (ess.getSettings().isCustomJoinMessage())
{ {
ess.broadcastMessage(ess.getSettings().customJoinMessage()); ess.broadcastMessage(ess.getSettings().getCustomJoinMessage());
} }
else else
{ {
ess.broadcastMessage(message); ess.broadcastMessage(message);
} }
if (!player.isOnline()) if (!player.isOnline())
{ {
return; return;

View file

@ -198,9 +198,13 @@ public interface ISettings extends IConf
int getMaxUserCacheCount(); int getMaxUserCacheCount();
boolean isJoinQuitMessagesDisabled(); boolean allowSilentJoinQuit();
String customJoinMessage(); boolean isCustomJoinMessage();
String customQuitMessage(); String getCustomJoinMessage();
boolean isCustomQuitMessage();
String getCustomQuitMessage();
} }

View file

@ -519,7 +519,11 @@ public class Settings implements net.ess3.api.ISettings
economyLog = _isEcoLogEnabled(); economyLog = _isEcoLogEnabled();
economyLogUpdate = _isEcoLogUpdateEnabled(); economyLogUpdate = _isEcoLogUpdateEnabled();
economyDisabled = _isEcoDisabled(); economyDisabled = _isEcoDisabled();
joinQuitMessagesDisabled = _isJoinQuitMessagesDisabled(); allowSilentJoin = _isJoinQuitMessagesDisabled();
customJoinMessage = _getCustomJoinMessage();
isCustomJoinMessage = !customJoinMessage.equals("none");
customQuitMessage = _getCustomQuitMessage();
isCustomQuitMessage = !customQuitMessage.equals("none");
} }
private List<Integer> itemSpawnBl = new ArrayList<Integer>(); private List<Integer> itemSpawnBl = new ArrayList<Integer>();
@ -1113,8 +1117,7 @@ public class Settings implements net.ess3.api.ISettings
{ {
return config.getInt("max-nick-length", 30); return config.getInt("max-nick-length", 30);
} }
private boolean allowSilentJoin;
private boolean joinQuitMessagesDisabled;
public boolean _isJoinQuitMessagesDisabled() public boolean _isJoinQuitMessagesDisabled()
{ {
@ -1122,21 +1125,47 @@ public class Settings implements net.ess3.api.ISettings
} }
@Override @Override
public boolean isJoinQuitMessagesDisabled() public boolean allowSilentJoinQuit()
{ {
return joinQuitMessagesDisabled; return allowSilentJoin;
}
private String customJoinMessage;
private boolean isCustomJoinMessage;
public String _getCustomJoinMessage()
{
return config.getString("custom-join-message", "none");
} }
@Override @Override
public String customJoinMessage() public String getCustomJoinMessage()
{ {
return config.getString("custom-join-message"); return customJoinMessage;
} }
@Override @Override
public String customQuitMessage() public boolean isCustomJoinMessage()
{ {
return config.getString("custom-quit-message"); return isCustomJoinMessage;
}
private String customQuitMessage;
private boolean isCustomQuitMessage;
public String _getCustomQuitMessage()
{
return config.getString("custom-quit-message", "none");
}
@Override
public String getCustomQuitMessage()
{
return customQuitMessage;
}
@Override
public boolean isCustomQuitMessage()
{
return isCustomQuitMessage;
} }
// #easteregg // #easteregg

View file

@ -7,7 +7,6 @@ import com.earth2me.essentials.User;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import org.bukkit.Bukkit;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.World; import org.bukkit.World;
@ -27,7 +26,6 @@ public class Commandremove extends EssentialsCommand
{ {
World world = user.getWorld(); World world = user.getWorld();
int radius = 0; int radius = 0;
Bukkit.broadcastMessage("len: " + args.length);
if (args.length >= 2) if (args.length >= 2)
{ {
try try

View file

@ -353,14 +353,15 @@ cancel-afk-on-move: true
# You can disable the death messages of Minecraft here. # You can disable the death messages of Minecraft here.
death-messages: true death-messages: true
# You can disable join and quit messages here. # Should operators be able to join and part silently.
# You can control this with permissions if it is enabled.
allow-silent-join-quit: false allow-silent-join-quit: false
# You can set a custom join message here, set to "none" to disable. # You can set a custom join message here, set to "none" to disable.
custom-join-message: none custom-join-message: "none"
# You can set a custom quit message here, set to "none" to disable. # You can set a custom quit message here, set to "none" to disable.
custom-quit-message: none custom-quit-message: "none"
# Add worlds to this list, if you want to automatically disable god mode there. # Add worlds to this list, if you want to automatically disable god mode there.
no-god-in-worlds: no-god-in-worlds: