mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-30 02:05:41 +00:00
Attempt to resolve banning issues (#96)
This commit is contained in:
parent
25aa28194b
commit
af777f1a76
@ -1,6 +1,7 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
@ -13,6 +14,9 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Temporarily bans a player for five minutes.", usage = "/<command> <player> [reason]", aliases = "noob")
|
||||
public class Command_tban extends FreedomCommand
|
||||
@ -26,14 +30,22 @@ public class Command_tban extends FreedomCommand
|
||||
return false;
|
||||
}
|
||||
|
||||
final String username;
|
||||
final List<String> ips = new ArrayList<>();
|
||||
|
||||
final Player player = getPlayer(args[0]);
|
||||
final PlayerData entry = plugin.pl.getData(args[0]);
|
||||
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
msg(FreedomCommand.PLAYER_NOT_FOUND, ChatColor.RED);
|
||||
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
username = entry.getUsername();
|
||||
ips.addAll(entry.getIps());
|
||||
|
||||
String reason;
|
||||
if (args.length > 1)
|
||||
{
|
||||
@ -56,8 +68,12 @@ public class Command_tban extends FreedomCommand
|
||||
}
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Tempbanning: " + player.getName() + " for 5 minutes.", true);
|
||||
plugin.bm.addBan(Ban.forPlayer(player, sender, FUtil.parseDateOffset("5m"), reason));
|
||||
|
||||
Ban ban = Ban.forPlayerName(username, sender, FUtil.parseDateOffset("5m"), reason);
|
||||
for (String ip : ips)
|
||||
{
|
||||
ban.addIp(ip);
|
||||
}
|
||||
plugin.bm.addBan(ban);
|
||||
player.kickPlayer(ChatColor.RED + "You have been temporarily banned for five minutes. Please read totalfreedom.me for more info.");
|
||||
|
||||
plugin.pul.logPunishment(new Punishment(player.getName(), Ips.getIp(player), sender.getName(), PunishmentType.TEMPBAN, reason));
|
||||
|
@ -1,8 +1,7 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
@ -15,6 +14,11 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Temporarily ban someone.", usage = "/<command> [playername] [duration] [reason]")
|
||||
public class Command_tempban extends FreedomCommand
|
||||
@ -30,7 +34,12 @@ public class Command_tempban extends FreedomCommand
|
||||
return false;
|
||||
}
|
||||
|
||||
final String username;
|
||||
final List<String> ips = new ArrayList<>();
|
||||
|
||||
final Player player = getPlayer(args[0]);
|
||||
final PlayerData entry = plugin.pl.getData(args[0]);
|
||||
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
@ -38,6 +47,8 @@ public class Command_tempban extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
username = entry.getUsername();
|
||||
ips.addAll(entry.getIps());
|
||||
final StringBuilder message = new StringBuilder("Temporarily banned " + player.getName());
|
||||
|
||||
Date expires = FUtil.parseDateOffset("30m");
|
||||
@ -71,8 +82,12 @@ public class Command_tempban extends FreedomCommand
|
||||
|
||||
FUtil.adminAction(sender.getName(), message.toString(), true);
|
||||
|
||||
plugin.bm.addBan(Ban.forPlayer(player, sender, expires, reason));
|
||||
|
||||
Ban ban = Ban.forPlayerName(username, sender, expires, reason);
|
||||
for (String ip : ips)
|
||||
{
|
||||
ban.addIp(ip);
|
||||
}
|
||||
plugin.bm.addBan(ban);
|
||||
player.kickPlayer(sender.getName() + " - " + message.toString());
|
||||
|
||||
plugin.pul.logPunishment(new Punishment(player.getName(), Ips.getIp(player), sender.getName(), PunishmentType.TEMPBAN, reason));
|
||||
|
@ -27,7 +27,7 @@ public class Command_unban extends FreedomCommand
|
||||
|
||||
if (entry == null)
|
||||
{
|
||||
msg("Can't find that user.");
|
||||
msg("Can't find that user. If target is not logged in, make sure that you spelled the name exactly.");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -52,7 +52,6 @@ public class Command_unban extends FreedomCommand
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user