mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-09-06 21:18:03 +02:00
Merge branch 'master' of github.com:essentials/Essentials
This commit is contained in:
commit
18c9c812d7
@ -84,6 +84,7 @@ public class Essentials extends JavaPlugin implements IEssentials
|
|||||||
private transient ExecuteTimer execTimer;
|
private transient ExecuteTimer execTimer;
|
||||||
private transient I18n i18n;
|
private transient I18n i18n;
|
||||||
private transient Metrics metrics;
|
private transient Metrics metrics;
|
||||||
|
private transient EssentialsTimer timer;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ISettings getSettings()
|
public ISettings getSettings()
|
||||||
@ -238,8 +239,9 @@ public class Essentials extends JavaPlugin implements IEssentials
|
|||||||
|
|
||||||
pm.registerEvents(tntListener, this);
|
pm.registerEvents(tntListener, this);
|
||||||
|
|
||||||
final EssentialsTimer timer = new EssentialsTimer(this);
|
timer = new EssentialsTimer(this);
|
||||||
getScheduler().scheduleSyncRepeatingTask(this, timer, 1, 100);
|
getScheduler().scheduleSyncRepeatingTask(this, timer, 1, 100);
|
||||||
|
|
||||||
Economy.setEss(this);
|
Economy.setEss(this);
|
||||||
execTimer.mark("RegListeners");
|
execTimer.mark("RegListeners");
|
||||||
|
|
||||||
@ -264,6 +266,13 @@ public class Essentials extends JavaPlugin implements IEssentials
|
|||||||
@Override
|
@Override
|
||||||
public void onDisable()
|
public void onDisable()
|
||||||
{
|
{
|
||||||
|
for (Player p : getServer().getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (getUser(p).isVanished())
|
||||||
|
{
|
||||||
|
p.sendMessage(ChatColor.RED + _("unvanishedReload"));
|
||||||
|
}
|
||||||
|
}
|
||||||
i18n.onDisable();
|
i18n.onDisable();
|
||||||
Economy.setEss(null);
|
Economy.setEss(null);
|
||||||
Trade.closeLog();
|
Trade.closeLog();
|
||||||
@ -614,6 +623,11 @@ public class Essentials extends JavaPlugin implements IEssentials
|
|||||||
return i18n;
|
return i18n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EssentialsTimer getTimer()
|
||||||
|
{
|
||||||
|
return timer;
|
||||||
|
}
|
||||||
|
|
||||||
private static class EssentialsWorldListener implements Listener, Runnable
|
private static class EssentialsWorldListener implements Listener, Runnable
|
||||||
{
|
{
|
||||||
|
@ -2,6 +2,7 @@ package com.earth2me.essentials;
|
|||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -11,6 +12,8 @@ public class EssentialsTimer implements Runnable
|
|||||||
{
|
{
|
||||||
private final transient IEssentials ess;
|
private final transient IEssentials ess;
|
||||||
private final transient Set<User> onlineUsers = new HashSet<User>();
|
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)
|
EssentialsTimer(final IEssentials ess)
|
||||||
{
|
{
|
||||||
@ -21,6 +24,21 @@ public class EssentialsTimer implements Runnable
|
|||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
final long currentTime = System.currentTimeMillis();
|
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())
|
for (Player player : ess.getServer().getOnlinePlayers())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -51,4 +69,17 @@ public class EssentialsTimer implements Runnable
|
|||||||
user.resetInvulnerabilityAfterTeleport();
|
user.resetInvulnerabilityAfterTeleport();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float getAverageTPS()
|
||||||
|
{
|
||||||
|
float avg = 0;
|
||||||
|
for (Float f : history)
|
||||||
|
{
|
||||||
|
if (f != null)
|
||||||
|
{
|
||||||
|
avg += f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return avg / history.size();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,4 +71,5 @@ public interface IEssentials extends Plugin
|
|||||||
|
|
||||||
void setMetrics(Metrics metrics);
|
void setMetrics(Metrics metrics);
|
||||||
|
|
||||||
|
EssentialsTimer getTimer();
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
|||||||
private CommandSender replyTo = null;
|
private CommandSender replyTo = null;
|
||||||
private transient User teleportRequester;
|
private transient User teleportRequester;
|
||||||
private transient boolean teleportRequestHere;
|
private transient boolean teleportRequestHere;
|
||||||
|
private transient boolean vanished;
|
||||||
private transient final Teleport teleport;
|
private transient final Teleport teleport;
|
||||||
private transient long teleportRequestTime;
|
private transient long teleportRequestTime;
|
||||||
private transient long lastOnlineActivity;
|
private transient long lastOnlineActivity;
|
||||||
@ -640,4 +641,14 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
|||||||
{
|
{
|
||||||
return teleportInvulnerabilityTimestamp != 0 && teleportInvulnerabilityTimestamp >= System.currentTimeMillis();
|
return teleportInvulnerabilityTimestamp != 0 && teleportInvulnerabilityTimestamp >= System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isVanished()
|
||||||
|
{
|
||||||
|
return vanished;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void toggleVanished()
|
||||||
|
{
|
||||||
|
vanished = !vanished;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.earth2me.essentials.commands;
|
package com.earth2me.essentials.commands;
|
||||||
|
|
||||||
import static com.earth2me.essentials.I18n._;
|
import static com.earth2me.essentials.I18n._;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -16,6 +17,21 @@ public class Commandgc extends EssentialsCommand
|
|||||||
@Override
|
@Override
|
||||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
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(_("gcmax", (Runtime.getRuntime().maxMemory() / 1024 / 1024)));
|
||||||
sender.sendMessage(_("gctotal", (Runtime.getRuntime().totalMemory() / 1024 / 1024)));
|
sender.sendMessage(_("gctotal", (Runtime.getRuntime().totalMemory() / 1024 / 1024)));
|
||||||
sender.sendMessage(_("gcfree", (Runtime.getRuntime().freeMemory() / 1024 / 1024)));
|
sender.sendMessage(_("gcfree", (Runtime.getRuntime().freeMemory() / 1024 / 1024)));
|
||||||
|
@ -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"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -364,6 +364,7 @@ tradeSignEmptyOwner=There is nothing to collect from this trade sign.
|
|||||||
treeFailure=\u00a7cTree generation failure. Try again on grass or dirt.
|
treeFailure=\u00a7cTree generation failure. Try again on grass or dirt.
|
||||||
treeSpawned=\u00a77Tree spawned.
|
treeSpawned=\u00a77Tree spawned.
|
||||||
true=true
|
true=true
|
||||||
|
tps=Current TPS = {0}
|
||||||
typeTpaccept=\u00a77To teleport, type \u00a7c/tpaccept\u00a77.
|
typeTpaccept=\u00a77To teleport, type \u00a7c/tpaccept\u00a77.
|
||||||
typeTpdeny=\u00a77To deny this request, type \u00a7c/tpdeny\u00a77.
|
typeTpdeny=\u00a77To deny this request, type \u00a7c/tpdeny\u00a77.
|
||||||
typeWorldName=\u00a77You can also type the name of a specific world.
|
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}.
|
unlimitedItemPermission=\u00a7cNo permission for unlimited item {0}.
|
||||||
unlimitedItems=Unlimited items:
|
unlimitedItems=Unlimited items:
|
||||||
unmutedPlayer=Player {0} unmuted.
|
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
|
upgradingFilesError=Error while upgrading the files
|
||||||
userDoesNotExist=The user {0} does not exist.
|
userDoesNotExist=The user {0} does not exist.
|
||||||
userIsAway={0} is now AFK
|
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}
|
userdataMoveBackError=Failed to move userdata/{0}.tmp to userdata/{1}
|
||||||
userdataMoveError=Failed to move userdata/{0} to userdata/{1}.tmp
|
userdataMoveError=Failed to move userdata/{0} to userdata/{1}.tmp
|
||||||
usingTempFolderForTesting=Using temp folder for testing:
|
usingTempFolderForTesting=Using temp folder for testing:
|
||||||
|
vanished=You have now been vanished.
|
||||||
versionMismatch=Version mismatch! Please update {0} to the same version.
|
versionMismatch=Version mismatch! Please update {0} to the same version.
|
||||||
versionMismatchAll=Version mismatch! Please update all Essentials jars to the same version.
|
versionMismatchAll=Version mismatch! Please update all Essentials jars to the same version.
|
||||||
voiceSilenced=\u00a77Your voice has been silenced
|
voiceSilenced=\u00a77Your voice has been silenced
|
||||||
|
@ -119,9 +119,9 @@ commands:
|
|||||||
usage: /<command> [player]
|
usage: /<command> [player]
|
||||||
aliases: [coords,egetpos,position,eposition,whereami,ewhereami]
|
aliases: [coords,egetpos,position,eposition,whereami,ewhereami]
|
||||||
gc:
|
gc:
|
||||||
description: Reports garbage collection info; useful to developers.
|
description: Reports garbage collection and tick info; useful to developers.
|
||||||
usage: /<command>
|
usage: /<command>
|
||||||
aliases: [mem,memory,egc,emem,ememory]
|
aliases: [elag,lag,mem,memory,egc,emem,ememory]
|
||||||
give:
|
give:
|
||||||
description: Give a player an item.
|
description: Give a player an item.
|
||||||
usage: /<command> <player> <item|numeric> [amount <enchantmentname[:level]> ...]
|
usage: /<command> <player> <item|numeric> [amount <enchantmentname[:level]> ...]
|
||||||
@ -405,6 +405,10 @@ commands:
|
|||||||
description: Allows the unlimited placing of items.
|
description: Allows the unlimited placing of items.
|
||||||
usage: /<command> <list|item|clear> [player]
|
usage: /<command> <list|item|clear> [player]
|
||||||
aliases: [eunlimited,ul,unl,eul,eunl]
|
aliases: [eunlimited,ul,unl,eul,eunl]
|
||||||
|
vanish:
|
||||||
|
description: Hide yourself from other players.
|
||||||
|
usage: /<command>
|
||||||
|
aliases: [evanish]
|
||||||
warp:
|
warp:
|
||||||
description: List all warps or warp to the specified location.
|
description: List all warps or warp to the specified location.
|
||||||
usage: /<command> <pagenumber|warp> [player]
|
usage: /<command> <pagenumber|warp> [player]
|
||||||
|
Loading…
Reference in New Issue
Block a user