mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-13 11:41:24 +01:00
Remove ban check from /ess cleanup, no longer required.
Fix ban upgrade script.
This commit is contained in:
parent
51be2131f7
commit
0c416c8366
@ -25,8 +25,6 @@ public class EssentialsUpgrade
|
||||
private final static Logger LOGGER = Logger.getLogger("Essentials");
|
||||
private final transient IEssentials ess;
|
||||
private final transient EssentialsConf doneFile;
|
||||
private String banReason;
|
||||
private Long banTimeout;
|
||||
|
||||
EssentialsUpgrade(final IEssentials essentials)
|
||||
{
|
||||
@ -676,36 +674,62 @@ public class EssentialsUpgrade
|
||||
{
|
||||
return;
|
||||
}
|
||||
File[] playerFiles = userdir.listFiles();
|
||||
|
||||
for (File pFile : playerFiles)
|
||||
int countFiles = 0;
|
||||
|
||||
ess.getLogger().info("Found " + userdir.list().length + " files to convert...");
|
||||
|
||||
for (String string : userdir.list())
|
||||
{
|
||||
EssentialsConf conf = new EssentialsConf(pFile);
|
||||
if (!string.endsWith(".yml") || string.length() < 5)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final int showProgress = countFiles % 250;
|
||||
|
||||
if (showProgress == 0)
|
||||
{
|
||||
ess.getLogger().info("Converted " + countFiles + "/" + userdir.list().length);
|
||||
}
|
||||
|
||||
countFiles++;
|
||||
final File pFile = new File(userdir, string);
|
||||
final EssentialsConf conf = new EssentialsConf(pFile);
|
||||
conf.load();
|
||||
|
||||
String banReason;
|
||||
Long banTimeout;
|
||||
|
||||
try
|
||||
{
|
||||
banReason = conf.getConfigurationSection("ban").getString("reason");
|
||||
}
|
||||
catch (NullPointerException n)
|
||||
{
|
||||
//No ban in userfile
|
||||
banReason = "";
|
||||
banReason = null;
|
||||
}
|
||||
|
||||
String playerName = conf.getString("lastAccountName");
|
||||
if (!banReason.equals(""))
|
||||
final String playerName = conf.getString("lastAccountName");
|
||||
if (playerName != null && playerName.length() > 1 && banReason != null && banReason.length() > 1)
|
||||
{
|
||||
try
|
||||
{
|
||||
banTimeout = Long.parseLong(conf.getConfigurationSection("ban").getString("timeout"));
|
||||
if (conf.getConfigurationSection("ban").contains("timeout"))
|
||||
{
|
||||
banTimeout = Long.parseLong(conf.getConfigurationSection("ban").getString("timeout"));
|
||||
}
|
||||
else
|
||||
{
|
||||
banTimeout = 0L;
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException n)
|
||||
{
|
||||
//No ban timeout set, or malformed timeout.
|
||||
banTimeout = 0L;
|
||||
}
|
||||
org.bukkit.OfflinePlayer player = ess.getServer().getOfflinePlayer(playerName);
|
||||
if (player.isBanned())
|
||||
|
||||
if (ess.getServer().getBanList(BanList.Type.NAME).isBanned(playerName))
|
||||
{
|
||||
updateBan(playerName, banReason, banTimeout);
|
||||
}
|
||||
|
@ -62,11 +62,13 @@ public class Commandban extends EssentialsCommand
|
||||
{
|
||||
banReason = tl("defaultBanReason");
|
||||
}
|
||||
|
||||
|
||||
Bukkit.getBanList(BanList.Type.NAME).addBan(user.getName(), banReason, null, senderName);
|
||||
user.getBase().kickPlayer(tl("banFormat", banReason, senderName));
|
||||
|
||||
server.getLogger().log(Level.INFO, tl("playerBanned", senderName, user.getName(), banReason));
|
||||
String banDisplay = tl("banFormat", banReason, senderName);
|
||||
|
||||
user.getBase().kickPlayer(banDisplay);
|
||||
server.getLogger().log(Level.INFO, tl("playerBanned", senderName, user.getName(), banDisplay));
|
||||
|
||||
if (nomatch)
|
||||
{
|
||||
|
@ -264,15 +264,14 @@ public class Commandessentials extends EssentialsCommand
|
||||
{
|
||||
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.");
|
||||
sender.sendMessage("Unless you define larger default values, this command wil ignore people who have more than 0 money/homes/bans.");
|
||||
throw new Exception("/<command> cleanup <days> [money] [homes] [ban count]");
|
||||
sender.sendMessage("Unless you define larger default values, this command wil ignore people who have more than 0 money/homes.");
|
||||
throw new Exception("/<command> cleanup <days> [money] [homes]");
|
||||
}
|
||||
sender.sendMessage(tl("cleaning"));
|
||||
|
||||
final long daysArg = Long.parseLong(args[1]);
|
||||
final double moneyArg = args.length >= 3 ? Double.parseDouble(args[2].replaceAll("[^0-9\\.]", "")) : 0;
|
||||
final int homesArg = args.length >= 4 && NumberUtil.isInt(args[3]) ? Integer.parseInt(args[3]) : 0;
|
||||
final int bansArg = args.length >= 5 && NumberUtil.isInt(args[4]) ? Integer.parseInt(args[4]) : 0;
|
||||
final UserMap userMap = ess.getUserMap();
|
||||
|
||||
ess.runTaskAsynchronously(new Runnable()
|
||||
@ -289,8 +288,6 @@ public class Commandessentials extends EssentialsCommand
|
||||
continue;
|
||||
}
|
||||
|
||||
int ban = user.getBase().isBanned() ? 0 : 1;
|
||||
|
||||
long lastLog = user.getLastLogout();
|
||||
if (lastLog == 0)
|
||||
{
|
||||
@ -311,7 +308,7 @@ public class Commandessentials extends EssentialsCommand
|
||||
int homeCount = user.getHomes().size();
|
||||
double moneyCount = user.getMoney().doubleValue();
|
||||
|
||||
if ((lastLog == 0) || (ban > bansArg) || (timeDiff < milliDays)
|
||||
if ((lastLog == 0) || (timeDiff < milliDays)
|
||||
|| (homeCount > homesArg) || (moneyCount > moneyArg))
|
||||
{
|
||||
continue;
|
||||
|
@ -56,13 +56,15 @@ public class Commandseen extends EssentialsCommand
|
||||
seenIP(server, sender, args[0]);
|
||||
return;
|
||||
}
|
||||
else if (FormatUtil.validIP(args[0]) && (server.getIPBans().contains(args[0])))
|
||||
else if (Bukkit.getBanList(BanList.Type.IP).isBanned(args[0]))
|
||||
{
|
||||
sender.sendMessage(tl("isIpBanned", args[0]));
|
||||
return;
|
||||
}
|
||||
else if (Bukkit.getBannedPlayers().contains(Bukkit.getOfflinePlayer(args[0]))) {
|
||||
sender.sendMessage(tl("whoisBanned", showBan ? Bukkit.getBanList(BanList.Type.NAME).getBanEntry(Bukkit.getOfflinePlayer(args[0]).getName()).getReason() : tl("true")));
|
||||
|
||||
else if (Bukkit.getBanList(BanList.Type.NAME).isBanned(args[0]))
|
||||
{
|
||||
sender.sendMessage(tl("whoisBanned", showBan ? Bukkit.getBanList(BanList.Type.NAME).getBanEntry(args[0]).getReason() : tl("true")));
|
||||
return;
|
||||
}
|
||||
else
|
||||
@ -168,7 +170,7 @@ public class Commandseen extends EssentialsCommand
|
||||
{
|
||||
final UserMap userMap = ess.getUserMap();
|
||||
|
||||
if (server.getIPBans().contains(ipAddress))
|
||||
if (Bukkit.getBanList(BanList.Type.IP).isBanned(ipAddress))
|
||||
{
|
||||
sender.sendMessage(tl("isIpBanned", ipAddress));
|
||||
}
|
||||
|
@ -47,8 +47,8 @@ public class Commandtempban extends EssentialsCommand
|
||||
}
|
||||
final String time = getFinalArg(args, 1);
|
||||
final long banTimestamp = DateUtil.parseDateDiff(time, true);
|
||||
String stringDregs = DateUtil.removeTimePattern(time);
|
||||
|
||||
String banReason = DateUtil.removeTimePattern(time);
|
||||
|
||||
final long maxBanLength = ess.getSettings().getMaxTempban() * 1000;
|
||||
if (maxBanLength > 0 && ((banTimestamp - GregorianCalendar.getInstance().getTimeInMillis()) > maxBanLength)
|
||||
&& sender.isPlayer() && !(ess.getUser(sender.getPlayer()).isAuthorized("essentials.tempban.unlimited")))
|
||||
@ -56,17 +56,18 @@ public class Commandtempban extends EssentialsCommand
|
||||
sender.sendMessage(tl("oversizedTempban"));
|
||||
throw new NoChargeException();
|
||||
}
|
||||
|
||||
if (stringDregs.length() < 2)
|
||||
|
||||
if (banReason.length() < 2)
|
||||
{
|
||||
stringDregs = tl("defaultBanReason");
|
||||
banReason = tl("defaultBanReason");
|
||||
}
|
||||
|
||||
final String senderName = sender.isPlayer() ? sender.getPlayer().getDisplayName() : Console.NAME;
|
||||
final String banReason = tl("tempBanned", DateUtil.formatDateDiff(banTimestamp), senderName, stringDregs);
|
||||
|
||||
Bukkit.getBanList(BanList.Type.NAME).addBan(user.getName(), banReason, new Date(banTimestamp), senderName);
|
||||
user.getBase().kickPlayer(banReason);
|
||||
|
||||
String banDisplay = tl("tempBanned", DateUtil.formatDateDiff(banTimestamp), senderName, banReason);
|
||||
user.getBase().kickPlayer(banDisplay);
|
||||
server.getLogger().log(Level.INFO, tl("playerBanned", senderName, user.getName(), banDisplay));
|
||||
|
||||
final String message = tl("playerBanned", senderName, user.getName(), banReason, DateUtil.formatDateDiff(banTimestamp));
|
||||
server.getLogger().log(Level.INFO, message);
|
||||
|
@ -27,7 +27,7 @@ balance=\u00a7aBalance\:\u00a7c {0}
|
||||
balanceOther=\u00a7aBalance of {0}\u00a7a\:\u00a7c {1}
|
||||
balanceTop=\u00a76Top balances ({0})
|
||||
banExempt=\u00a74You cannot ban that player.
|
||||
banFormat=\u00a74Banned\:\n\u00a7r{0}
|
||||
banFormat=\u00a7cYou have been banned\:\n\u00a7r{0}
|
||||
bed=\u00a7obed\u00a7r
|
||||
bedMissing=\u00a74Your bed is either unset, missing or blocked.
|
||||
bedNull=\u00a7mbed\u00a7r
|
||||
@ -155,7 +155,7 @@ holdBook=\u00a74You are not holding a writable book.
|
||||
holdFirework=\u00a74You must be holding a firework to add effects.
|
||||
holdPotion=\u00a74You must be holding a potion to apply effects to it.
|
||||
holeInFloor=\u00a74Hole in floor\!
|
||||
homeSet=\u00a76Home set.
|
||||
homeSet=\u00a76Home set to current location.
|
||||
homes=\u00a76Homes\:\u00a7r {0}
|
||||
hour=hour
|
||||
hours=hours
|
||||
@ -321,8 +321,8 @@ pWeatherPlayers=\u00a76These players have their own weather\:\u00a7r
|
||||
pWeatherReset=\u00a76Player weather has been reset for\: \u00a7c{0}
|
||||
pWeatherSet=\u00a76Player weather is set to \u00a7c{0}\u00a76 for\: \u00a7c{1}.
|
||||
pendingTeleportCancelled=\u00a74Pending teleportation request cancelled.
|
||||
playerBanIpAddress=\u00a76Player\u00a7c {0} \u00a76banned IP address\:\u00a7c {1}\u00a76.
|
||||
playerBanned=\u00a76Player\u00a7c {0} \u00a76banned\u00a7c {1} \u00a76for \u00a7c{2}\u00a76.
|
||||
playerBanIpAddress=\u00a76Player\u00a7c {0} \u00a76banned IP address\u00a7c {1} \u00a76for\: \u00a7c{2}\u00a76.
|
||||
playerBanned=\u00a76Player\u00a7c {0} \u00a76banned\u00a7c {1} \u00a76for\: \u00a7c{2}\u00a76.
|
||||
playerInJail=\u00a74Player is already in jail\u00a7c {0}\u00a74.
|
||||
playerJailed=\u00a76Player\u00a7c {0} \u00a76jailed.
|
||||
playerJailedFor=\u00a76Player\u00a7c {0} \u00a76jailed for {1}.
|
||||
@ -426,7 +426,7 @@ teleportationEnabled=\u00a76Teleportation \u00a7cenabled\u00a76.
|
||||
teleportationEnabledFor=\u00a76Teleportation \u00a7cenabled \u00a76for \u00a7c{0}\u00a76.
|
||||
teleporting=\u00a76Teleporting...
|
||||
teleportToPlayer=\u00a76Teleporting to \u00a7c{0}\u00a76.
|
||||
tempBanned=Temporarily banned from server for {0}.
|
||||
tempBanned=\u00a7cYou have been temporarily banned for {0}\:\n\u00a7r{2}
|
||||
tempbanExempt=\u00a74You may not tempban that player.
|
||||
thunder=\u00a76You\u00a7c {0} \u00a76thunder in your world.
|
||||
thunderDuration=\u00a76You\u00a7c {0} \u00a76thunder in your world for\u00a7c {1} \u00a76seconds.
|
||||
|
Loading…
Reference in New Issue
Block a user