mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-12 04:20:41 +00:00
Code cleanup
This commit is contained in:
parent
8710a133ce
commit
6ae6c51dc0
1 changed files with 65 additions and 73 deletions
|
@ -5,14 +5,10 @@ import com.earth2me.essentials.User;
|
|||
import com.earth2me.essentials.UserMap;
|
||||
import com.earth2me.essentials.Util;
|
||||
import com.earth2me.essentials.metrics.Metrics;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.bukkit.Instrument;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Note;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
|
@ -33,7 +29,8 @@ public class Commandessentials extends EssentialsCommand
|
|||
@Override
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length == 0) {
|
||||
if (args.length == 0)
|
||||
{
|
||||
run_disabled(server, sender, commandLabel, args);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("debug"))
|
||||
|
@ -75,12 +72,14 @@ public class Commandessentials extends EssentialsCommand
|
|||
final StringBuilder disabledCommands = new StringBuilder();
|
||||
for (Map.Entry<String, String> entry : ess.getAlternativeCommandsHandler().disabledCommands().entrySet())
|
||||
{
|
||||
if (disabledCommands.length() > 0) {
|
||||
if (disabledCommands.length() > 0)
|
||||
{
|
||||
disabledCommands.append(", ");
|
||||
}
|
||||
disabledCommands.append(entry.getKey()).append(" => ").append(entry.getValue());
|
||||
}
|
||||
if (disabledCommands.length() > 0) {
|
||||
if (disabledCommands.length() > 0)
|
||||
{
|
||||
sender.sendMessage(_("blockList"));
|
||||
sender.sendMessage(disabledCommands.toString());
|
||||
}
|
||||
|
@ -90,7 +89,7 @@ public class Commandessentials extends EssentialsCommand
|
|||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
throw new NotEnoughArgumentsException("/<command> reset <player>");
|
||||
throw new Exception("/<command> reset <player>");
|
||||
}
|
||||
final User user = getPlayer(server, args, 1, true);
|
||||
user.reset();
|
||||
|
@ -128,7 +127,7 @@ public class Commandessentials extends EssentialsCommand
|
|||
noteMap.put("2G", 1.06f);
|
||||
noteMap.put("2G#", 1.12f);
|
||||
noteMap.put("2A", 1.18f);
|
||||
noteMap.put("2A#",1.26f);
|
||||
noteMap.put("2A#", 1.26f);
|
||||
noteMap.put("2B", 1.34f);
|
||||
noteMap.put("2C", 1.42f);
|
||||
noteMap.put("2C#", 1.5f);
|
||||
|
@ -178,13 +177,19 @@ public class Commandessentials extends EssentialsCommand
|
|||
|
||||
private void run_moo(final Server server, final CommandSender sender, final String command, final String args[])
|
||||
{
|
||||
if(sender instanceof ConsoleCommandSender)
|
||||
if (sender instanceof ConsoleCommandSender)
|
||||
{
|
||||
sender.sendMessage(new String[]{" (__)", " (oo)", " /------\\/", " / | ||", " * /\\---/\\", " ~~ ~~", "....\"Have you mooed today?\"..." } );
|
||||
sender.sendMessage(new String[]
|
||||
{
|
||||
" (__)", " (oo)", " /------\\/", " / | ||", " * /\\---/\\", " ~~ ~~", "....\"Have you mooed today?\"..."
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
sender.sendMessage(new String[]{" (__)", " (oo)", " /------\\/", " / | | |", " * /\\---/\\", " ~~ ~~", "....\"Have you mooed today?\"..." } );
|
||||
sender.sendMessage(new String[]
|
||||
{
|
||||
" (__)", " (oo)", " /------\\/", " / | | |", " * /\\---/\\", " ~~ ~~", "....\"Have you mooed today?\"..."
|
||||
});
|
||||
Player player = (Player)sender;
|
||||
player.playSound(player.getLocation(), Sound.COW_IDLE, 1, 1.0f);
|
||||
}
|
||||
|
@ -211,12 +216,14 @@ public class Commandessentials extends EssentialsCommand
|
|||
sender.sendMessage("Unable to modify 'plugins/PluginMetrics/config.yml': " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void run_cleanup(final Server server, final CommandSender sender, final String command, final String args[]) throws Exception
|
||||
{
|
||||
|
||||
if (args.length < 2 || !Util.isInt(args[1]))
|
||||
{
|
||||
throw new NotEnoughArgumentsException("/<command> cleanup <days> [money] [homes] [bans]");
|
||||
sender.sendMessage("This sub-command will delete users who havent logged in in the last <days> days.");
|
||||
sender.sendMessage("Optional parameters define the minium amount required to prevent deletion.");
|
||||
throw new Exception("/<command> cleanup <days> [money] [homes] [ban count]");
|
||||
}
|
||||
sender.sendMessage(_("cleaning"));
|
||||
|
||||
|
@ -226,8 +233,7 @@ public class Commandessentials extends EssentialsCommand
|
|||
final int bansArg = args.length >= 5 && Util.isInt(args[4]) ? Integer.parseInt(args[4]) : 0;
|
||||
final UserMap userMap = ess.getUserMap();
|
||||
|
||||
|
||||
ess.runTaskAsynchronously( new Runnable()
|
||||
ess.runTaskAsynchronously(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
|
@ -239,32 +245,18 @@ public class Commandessentials extends EssentialsCommand
|
|||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
int ban = user.getBanReason().equals("") ? 0 : 1;
|
||||
if (!(ban <= bansArg))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
long lastLogout = user.getLastLogout();
|
||||
long timeNow = System.currentTimeMillis();
|
||||
long timeDiff = timeNow - lastLogout;
|
||||
long timeDiff = System.currentTimeMillis() - user.getLastLogout();
|
||||
long milliDays = daysArg * 24 * 60 * 60;
|
||||
if (!(timeDiff >= milliDays))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
int homes = user.getHomes().size();
|
||||
if (!(homes <= homesArg))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
double money = user.getMoney();
|
||||
if (!(money <= moneyArg))
|
||||
|
||||
if ((ban > bansArg) || (timeDiff < milliDays)
|
||||
|| (user.getHomes().size() > homesArg) || (user.getMoney() > moneyArg))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
user.reset();
|
||||
}
|
||||
userMap.reloadConfig();
|
||||
sender.sendMessage(_("cleaned"));
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue