mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-11-09 20:41:23 +01:00
Multiline kick messages and tempban countdown.
This commit is contained in:
parent
79004c7098
commit
341cb89bb7
@ -6,7 +6,6 @@ import com.earth2me.essentials.textreader.KeywordReplacer;
|
||||
import com.earth2me.essentials.textreader.TextInput;
|
||||
import com.earth2me.essentials.textreader.TextPager;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@ -307,8 +306,17 @@ public class EssentialsPlayerListener implements Listener
|
||||
|
||||
if (!banExpired && (user.isBanned() || event.getResult() == Result.KICK_BANNED))
|
||||
{
|
||||
final String banReason = user.getBanReason();
|
||||
event.disallow(Result.KICK_BANNED, banReason != null && !banReason.isEmpty() && !banReason.equalsIgnoreCase("ban") ? banReason : _("defaultBanReason"));
|
||||
String banReason = user.getBanReason();
|
||||
if (banReason == null || banReason.isEmpty() || banReason.equalsIgnoreCase("ban"))
|
||||
{
|
||||
banReason = _("defaultBanReason");
|
||||
}
|
||||
if (user.getBanTimeout() > 0)
|
||||
{
|
||||
//TODO: TL This
|
||||
banReason += "\n\n" + "Expires in " + Util.formatDateDiff(user.getBanTimeout());
|
||||
}
|
||||
event.disallow(Result.KICK_BANNED, banReason);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -25,9 +25,11 @@ public class Commandkick extends EssentialsCommand
|
||||
}
|
||||
|
||||
final User target = getPlayer(server, args, 0, true);
|
||||
if (sender instanceof Player) {
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
User user = ess.getUser(sender);
|
||||
if (target.isHidden() && !user.isAuthorized("essentials.list.hidden")) {
|
||||
if (target.isHidden() && !user.isAuthorized("essentials.list.hidden"))
|
||||
{
|
||||
throw new PlayerNotFoundException();
|
||||
}
|
||||
if (target.isAuthorized("essentials.kick.exempt"))
|
||||
@ -35,10 +37,13 @@ public class Commandkick extends EssentialsCommand
|
||||
throw new Exception(_("kickExempt"));
|
||||
}
|
||||
}
|
||||
final String kickReason = args.length > 1 ? getFinalArg(args, 1) : _("kickDefault");
|
||||
|
||||
String kickReason = args.length > 1 ? getFinalArg(args, 1) : _("kickDefault");
|
||||
kickReason = kickReason.replace("\\n", "\n");
|
||||
|
||||
target.kickPlayer(kickReason);
|
||||
final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
|
||||
|
||||
|
||||
server.getLogger().log(Level.INFO, _("playerKicked", senderName, target.getName(), kickReason));
|
||||
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
|
@ -16,6 +16,9 @@ public class Commandkickall extends EssentialsCommand
|
||||
@Override
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
String kickReason = args.length > 0 ? getFinalArg(args, 0) : _("kickDefault");
|
||||
kickReason = kickReason.replace("\\n", "\n");
|
||||
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
{
|
||||
if (sender instanceof Player && onlinePlayer.getName().equalsIgnoreCase(((Player)sender).getName()))
|
||||
@ -24,7 +27,7 @@ public class Commandkickall extends EssentialsCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
onlinePlayer.kickPlayer(args.length > 0 ? getFinalArg(args, 0) : _("kickDefault"));
|
||||
onlinePlayer.kickPlayer(kickReason);
|
||||
}
|
||||
}
|
||||
sender.sendMessage(_("kickedAll"));
|
||||
|
@ -4,7 +4,6 @@ import com.earth2me.essentials.Console;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -47,7 +46,7 @@ public class Commandtempban extends EssentialsCommand
|
||||
final long banTimestamp = Util.parseDateDiff(time, true);
|
||||
|
||||
final long maxBanLength = ess.getSettings().getMaxTempban() * 1000;
|
||||
if(maxBanLength > 0 && ((banTimestamp - GregorianCalendar.getInstance().getTimeInMillis()) > maxBanLength) && !(ess.getUser(sender).isAuthorized("essentials.tempban.unlimited")))
|
||||
if (maxBanLength > 0 && ((banTimestamp - GregorianCalendar.getInstance().getTimeInMillis()) > maxBanLength) && !(ess.getUser(sender).isAuthorized("essentials.tempban.unlimited")))
|
||||
{
|
||||
sender.sendMessage(_("oversizedTempban"));
|
||||
throw new NoChargeException();
|
||||
|
Loading…
Reference in New Issue
Block a user