summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Essentials/src/com/earth2me/essentials/ISettings.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/Settings.java21
-rw-r--r--Essentials/src/com/earth2me/essentials/perm/PermissionsHandler.java43
3 files changed, 53 insertions, 13 deletions
diff --git a/Essentials/src/com/earth2me/essentials/ISettings.java b/Essentials/src/com/earth2me/essentials/ISettings.java
index a3bc8e290..beab3574a 100644
--- a/Essentials/src/com/earth2me/essentials/ISettings.java
+++ b/Essentials/src/com/earth2me/essentials/ISettings.java
@@ -193,6 +193,8 @@ public interface ISettings extends IConf
int getMailsPerMinute();
long getEconomyLagWarning();
+
+ long getPermissionsLagWarning();
void setEssentialsChatActive(boolean b);
diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java
index d653ec86c..b4eea4705 100644
--- a/Essentials/src/com/earth2me/essentials/Settings.java
+++ b/Essentials/src/com/earth2me/essentials/Settings.java
@@ -557,6 +557,7 @@ public class Settings implements net.ess3.api.ISettings
mailsPerMinute = _getMailsPerMinute();
maxMoney = _getMaxMoney();
minMoney = _getMinMoney();
+ permissionsLagWarning = _getPermissionsLagWarning();
economyLagWarning = _getEconomyLagWarning();
economyLog = _isEcoLogEnabled();
economyLogUpdate = _isEcoLogUpdateEnabled();
@@ -1137,8 +1138,8 @@ public class Settings implements net.ess3.api.ISettings
private long _getEconomyLagWarning()
{
- // Default to 20ms
- final long value = (long)(config.getDouble("economy-lag-warning", 20.0) * 1000000);
+ // Default to 25ms
+ final long value = (long)(config.getDouble("economy-lag-warning", 25.0) * 1000000);
return value;
}
@@ -1147,6 +1148,22 @@ public class Settings implements net.ess3.api.ISettings
{
return economyLagWarning;
}
+
+ // #easteregg
+ private long permissionsLagWarning;
+
+ private long _getPermissionsLagWarning()
+ {
+ // Default to 25ms
+ final long value = (long)(config.getDouble("permissions-lag-warning", 25.0) * 1000000);
+ return value;
+ }
+
+ @Override
+ public long getPermissionsLagWarning()
+ {
+ return permissionsLagWarning;
+ }
@Override
public long getMaxTempban()
diff --git a/Essentials/src/com/earth2me/essentials/perm/PermissionsHandler.java b/Essentials/src/com/earth2me/essentials/perm/PermissionsHandler.java
index 7ee97d2b1..f92027afa 100644
--- a/Essentials/src/com/earth2me/essentials/perm/PermissionsHandler.java
+++ b/Essentials/src/com/earth2me/essentials/perm/PermissionsHandler.java
@@ -1,5 +1,6 @@
package com.earth2me.essentials.perm;
+import com.earth2me.essentials.Essentials;
import java.util.Collections;
import java.util.List;
import java.util.logging.Level;
@@ -13,46 +14,50 @@ public class PermissionsHandler implements IPermissionsHandler
{
private transient IPermissionsHandler handler = new NullPermissionsHandler();
private transient String defaultGroup = "default";
- private final transient Plugin plugin;
+ private final transient Essentials ess;
private static final Logger LOGGER = Logger.getLogger("Essentials");
private transient boolean useSuperperms = false;
- public PermissionsHandler(final Plugin plugin)
+ public PermissionsHandler(final Essentials plugin)
{
- this.plugin = plugin;
+ this.ess = plugin;
}
- public PermissionsHandler(final Plugin plugin, final boolean useSuperperms)
+ public PermissionsHandler(final Essentials plugin, final boolean useSuperperms)
{
- this.plugin = plugin;
+ this.ess = plugin;
this.useSuperperms = useSuperperms;
}
- public PermissionsHandler(final Plugin plugin, final String defaultGroup)
+ public PermissionsHandler(final Essentials plugin, final String defaultGroup)
{
- this.plugin = plugin;
+ this.ess = plugin;
this.defaultGroup = defaultGroup;
}
@Override
public String getGroup(final Player base)
{
+ final long start = System.nanoTime();
String group = handler.getGroup(base);
if (group == null)
{
group = defaultGroup;
}
+ checkPermLag(start);
return group;
}
@Override
public List<String> getGroups(final Player base)
{
+ final long start = System.nanoTime();
List<String> groups = handler.getGroups(base);
if (groups == null || groups.isEmpty())
{
groups = Collections.singletonList(defaultGroup);
}
+ checkPermLag(start);
return Collections.unmodifiableList(groups);
}
@@ -65,7 +70,10 @@ public class PermissionsHandler implements IPermissionsHandler
@Override
public boolean inGroup(final Player base, final String group)
{
- return handler.inGroup(base, group);
+ final long start = System.nanoTime();
+ final boolean result = handler.inGroup(base, group);
+ checkPermLag(start);
+ return result;
}
@Override
@@ -77,28 +85,32 @@ public class PermissionsHandler implements IPermissionsHandler
@Override
public String getPrefix(final Player base)
{
+ final long start = System.nanoTime();
String prefix = handler.getPrefix(base);
if (prefix == null)
{
prefix = "";
}
+ checkPermLag(start);
return prefix;
}
@Override
public String getSuffix(final Player base)
{
+ final long start = System.nanoTime();
String suffix = handler.getSuffix(base);
if (suffix == null)
{
suffix = "";
}
+ checkPermLag(start);
return suffix;
}
public void checkPermissions()
{
- final PluginManager pluginManager = plugin.getServer().getPluginManager();
+ final PluginManager pluginManager = ess.getServer().getPluginManager();
final Plugin permExPlugin = pluginManager.getPlugin("PermissionsEx");
if (permExPlugin != null && permExPlugin.isEnabled())
@@ -172,7 +184,7 @@ public class PermissionsHandler implements IPermissionsHandler
if (!(handler instanceof ZPermissionsHandler))
{
LOGGER.log(Level.INFO, "Essentials: Using zPermissions based permissions.");
- handler = new ZPermissionsHandler(plugin);
+ handler = new ZPermissionsHandler(ess);
}
return;
}
@@ -191,7 +203,7 @@ public class PermissionsHandler implements IPermissionsHandler
{
LOGGER.log(Level.INFO, "Essentials: Using config file enhanced permissions.");
LOGGER.log(Level.INFO, "Permissions listed in as player-commands will be given to all users.");
- handler = new ConfigPermissionsHandler(plugin);
+ handler = new ConfigPermissionsHandler(ess);
}
}
}
@@ -205,4 +217,13 @@ public class PermissionsHandler implements IPermissionsHandler
{
return handler.getClass().getSimpleName().replace("Handler", "");
}
+
+ private void checkPermLag(long start)
+ {
+ final long elapsed = System.nanoTime() - start;
+ if (elapsed > ess.getSettings().getPermissionsLagWarning())
+ {
+ ess.getLogger().log(Level.INFO, "Lag Notice - Slow Permissions System (" + getName() + ") Response - Request took over {0}ms!", elapsed / 1000000.0);
+ }
+ }
}