summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2012-05-19 17:45:09 +0100
committerKHobbits <rob@khobbits.co.uk>2012-05-19 17:45:09 +0100
commit18c9c812d7265549c9163ed1c4f75ed1b44ea66c (patch)
treeb49d545a63a836b57676c8fc2bca76a2a3d5ab43
parentbc798977b5db9d42800aadbd0a062c019866d8da (diff)
parent3eac027ddb165adc05eeebeed36727a0d837d938 (diff)
downloadEssentials-18c9c812d7265549c9163ed1c4f75ed1b44ea66c.tar
Essentials-18c9c812d7265549c9163ed1c4f75ed1b44ea66c.tar.gz
Essentials-18c9c812d7265549c9163ed1c4f75ed1b44ea66c.tar.lz
Essentials-18c9c812d7265549c9163ed1c4f75ed1b44ea66c.tar.xz
Essentials-18c9c812d7265549c9163ed1c4f75ed1b44ea66c.zip
Merge branch 'master' of github.com:essentials/Essentials
-rw-r--r--Essentials/src/com/earth2me/essentials/Essentials.java16
-rw-r--r--Essentials/src/com/earth2me/essentials/EssentialsTimer.java31
-rw-r--r--Essentials/src/com/earth2me/essentials/IEssentials.java1
-rw-r--r--Essentials/src/com/earth2me/essentials/User.java11
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandgc.java16
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandvanish.java40
-rw-r--r--Essentials/src/messages.properties4
-rw-r--r--Essentials/src/plugin.yml8
8 files changed, 124 insertions, 3 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java
index 6197f5edd..fe1edb4e5 100644
--- a/Essentials/src/com/earth2me/essentials/Essentials.java
+++ b/Essentials/src/com/earth2me/essentials/Essentials.java
@@ -84,6 +84,7 @@ public class Essentials extends JavaPlugin implements IEssentials
private transient ExecuteTimer execTimer;
private transient I18n i18n;
private transient Metrics metrics;
+ private transient EssentialsTimer timer;
@Override
public ISettings getSettings()
@@ -238,8 +239,9 @@ public class Essentials extends JavaPlugin implements IEssentials
pm.registerEvents(tntListener, this);
- final EssentialsTimer timer = new EssentialsTimer(this);
+ timer = new EssentialsTimer(this);
getScheduler().scheduleSyncRepeatingTask(this, timer, 1, 100);
+
Economy.setEss(this);
execTimer.mark("RegListeners");
@@ -264,6 +266,13 @@ public class Essentials extends JavaPlugin implements IEssentials
@Override
public void onDisable()
{
+ for (Player p : getServer().getOnlinePlayers())
+ {
+ if (getUser(p).isVanished())
+ {
+ p.sendMessage(ChatColor.RED + _("unvanishedReload"));
+ }
+ }
i18n.onDisable();
Economy.setEss(null);
Trade.closeLog();
@@ -614,6 +623,11 @@ public class Essentials extends JavaPlugin implements IEssentials
return i18n;
}
+ @Override
+ public EssentialsTimer getTimer()
+ {
+ return timer;
+ }
private static class EssentialsWorldListener implements Listener, Runnable
{
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsTimer.java b/Essentials/src/com/earth2me/essentials/EssentialsTimer.java
index 18f980a62..0d97c2792 100644
--- a/Essentials/src/com/earth2me/essentials/EssentialsTimer.java
+++ b/Essentials/src/com/earth2me/essentials/EssentialsTimer.java
@@ -2,6 +2,7 @@ package com.earth2me.essentials;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.Set;
import java.util.logging.Level;
import org.bukkit.entity.Player;
@@ -11,6 +12,8 @@ public class EssentialsTimer implements Runnable
{
private final transient IEssentials ess;
private final transient Set<User> onlineUsers = new HashSet<User>();
+ private transient long lastPoll = System.currentTimeMillis() - 3000;
+ private final transient LinkedList<Float> history = new LinkedList<Float>();
EssentialsTimer(final IEssentials ess)
{
@@ -21,6 +24,21 @@ public class EssentialsTimer implements Runnable
public void run()
{
final long currentTime = System.currentTimeMillis();
+ long timeSpent = (currentTime - lastPoll) / 1000;
+ if (timeSpent == 0)
+ {
+ timeSpent = 1;
+ }
+ if (history.size() > 10)
+ {
+ history.remove();
+ }
+ float tps = 100f / timeSpent;
+ if (tps <= 20)
+ {
+ history.add(tps);
+ }
+ lastPoll = currentTime;
for (Player player : ess.getServer().getOnlinePlayers())
{
try
@@ -51,4 +69,17 @@ public class EssentialsTimer implements Runnable
user.resetInvulnerabilityAfterTeleport();
}
}
+
+ public float getAverageTPS()
+ {
+ float avg = 0;
+ for (Float f : history)
+ {
+ if (f != null)
+ {
+ avg += f;
+ }
+ }
+ return avg / history.size();
+ }
}
diff --git a/Essentials/src/com/earth2me/essentials/IEssentials.java b/Essentials/src/com/earth2me/essentials/IEssentials.java
index 83c2e7325..6e1887b87 100644
--- a/Essentials/src/com/earth2me/essentials/IEssentials.java
+++ b/Essentials/src/com/earth2me/essentials/IEssentials.java
@@ -71,4 +71,5 @@ public interface IEssentials extends Plugin
void setMetrics(Metrics metrics);
+ EssentialsTimer getTimer();
}
diff --git a/Essentials/src/com/earth2me/essentials/User.java b/Essentials/src/com/earth2me/essentials/User.java
index 14660d8b8..c6ce3a569 100644
--- a/Essentials/src/com/earth2me/essentials/User.java
+++ b/Essentials/src/com/earth2me/essentials/User.java
@@ -17,6 +17,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
private CommandSender replyTo = null;
private transient User teleportRequester;
private transient boolean teleportRequestHere;
+ private transient boolean vanished;
private transient final Teleport teleport;
private transient long teleportRequestTime;
private transient long lastOnlineActivity;
@@ -640,4 +641,14 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
{
return teleportInvulnerabilityTimestamp != 0 && teleportInvulnerabilityTimestamp >= System.currentTimeMillis();
}
+
+ public boolean isVanished()
+ {
+ return vanished;
+ }
+
+ public void toggleVanished()
+ {
+ vanished = !vanished;
+ }
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgc.java b/Essentials/src/com/earth2me/essentials/commands/Commandgc.java
index 9429bc5a8..d9b08b50f 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandgc.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandgc.java
@@ -1,6 +1,7 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
+import org.bukkit.ChatColor;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
@@ -16,6 +17,21 @@ public class Commandgc extends EssentialsCommand
@Override
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
+ float tps = ess.getTimer().getAverageTPS();
+ ChatColor color;
+ if (tps >= 18)
+ {
+ color = ChatColor.GREEN;
+ }
+ else if (tps >= 15)
+ {
+ color = ChatColor.YELLOW;
+ }
+ else
+ {
+ color = ChatColor.RED;
+ }
+ sender.sendMessage(_("tps", "" + color + tps));
sender.sendMessage(_("gcmax", (Runtime.getRuntime().maxMemory() / 1024 / 1024)));
sender.sendMessage(_("gctotal", (Runtime.getRuntime().totalMemory() / 1024 / 1024)));
sender.sendMessage(_("gcfree", (Runtime.getRuntime().freeMemory() / 1024 / 1024)));
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandvanish.java b/Essentials/src/com/earth2me/essentials/commands/Commandvanish.java
new file mode 100644
index 000000000..96cf95e36
--- /dev/null
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandvanish.java
@@ -0,0 +1,40 @@
+package com.earth2me.essentials.commands;
+
+import static com.earth2me.essentials.I18n._;
+import com.earth2me.essentials.User;
+import org.bukkit.ChatColor;
+import org.bukkit.Server;
+import org.bukkit.entity.Player;
+
+
+public class Commandvanish extends EssentialsCommand
+{
+ public Commandvanish()
+ {
+ super("vanish");
+ }
+
+ @Override
+ protected void run(Server server, User user, String commandLabel, String[] args) throws Exception
+ {
+ if (user.isVanished())
+ {
+ for (Player p : server.getOnlinePlayers())
+ {
+ p.showPlayer(user);
+ }
+ user.sendMessage(ChatColor.GREEN + _("vanished"));
+ }
+ else
+ {
+ for (Player p : server.getOnlinePlayers())
+ {
+ if (!ess.getUser(p).isAuthorized("essentials.vanish.see"))
+ {
+ p.hidePlayer(user);
+ }
+ user.sendMessage(ChatColor.GREEN + _("unvanished"));
+ }
+ }
+ }
+}
diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties
index 73ce00bee..11ed0d74b 100644
--- a/Essentials/src/messages.properties
+++ b/Essentials/src/messages.properties
@@ -364,6 +364,7 @@ tradeSignEmptyOwner=There is nothing to collect from this trade sign.
treeFailure=\u00a7cTree generation failure. Try again on grass or dirt.
treeSpawned=\u00a77Tree spawned.
true=true
+tps=Current TPS = {0}
typeTpaccept=\u00a77To teleport, type \u00a7c/tpaccept\u00a77.
typeTpdeny=\u00a77To deny this request, type \u00a7c/tpdeny\u00a77.
typeWorldName=\u00a77You can also type the name of a specific world.
@@ -377,6 +378,8 @@ unknownItemName=Unknown item name: {0}
unlimitedItemPermission=\u00a7cNo permission for unlimited item {0}.
unlimitedItems=Unlimited items:
unmutedPlayer=Player {0} unmuted.
+unvanished=You are once again visible.
+unvanishedReload=A reload has forced you to become visible.
upgradingFilesError=Error while upgrading the files
userDoesNotExist=The user {0} does not exist.
userIsAway={0} is now AFK
@@ -386,6 +389,7 @@ userUsedPortal={0} used an existing exit portal.
userdataMoveBackError=Failed to move userdata/{0}.tmp to userdata/{1}
userdataMoveError=Failed to move userdata/{0} to userdata/{1}.tmp
usingTempFolderForTesting=Using temp folder for testing:
+vanished=You have now been vanished.
versionMismatch=Version mismatch! Please update {0} to the same version.
versionMismatchAll=Version mismatch! Please update all Essentials jars to the same version.
voiceSilenced=\u00a77Your voice has been silenced
diff --git a/Essentials/src/plugin.yml b/Essentials/src/plugin.yml
index 3e1dc52c0..d9d4179be 100644
--- a/Essentials/src/plugin.yml
+++ b/Essentials/src/plugin.yml
@@ -119,9 +119,9 @@ commands:
usage: /<command> [player]
aliases: [coords,egetpos,position,eposition,whereami,ewhereami]
gc:
- description: Reports garbage collection info; useful to developers.
+ description: Reports garbage collection and tick info; useful to developers.
usage: /<command>
- aliases: [mem,memory,egc,emem,ememory]
+ aliases: [elag,lag,mem,memory,egc,emem,ememory]
give:
description: Give a player an item.
usage: /<command> <player> <item|numeric> [amount <enchantmentname[:level]> ...]
@@ -405,6 +405,10 @@ commands:
description: Allows the unlimited placing of items.
usage: /<command> <list|item|clear> [player]
aliases: [eunlimited,ul,unl,eul,eunl]
+ vanish:
+ description: Hide yourself from other players.
+ usage: /<command>
+ aliases: [evanish]
warp:
description: List all warps or warp to the specified location.
usage: /<command> <pagenumber|warp> [player]