mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-12-28 12:47:36 +00:00
-q arg for more commands
- add `-q` arg for tban, warn, and tempban - add reasons to tban (#259)
This commit is contained in:
parent
86cf9dc344
commit
30d5a1d888
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@ -7,5 +7,5 @@
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" project-jdk-name="adopt-openj9-1.8" project-jdk-type="JavaSDK" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
|
||||
</project>
|
@ -8,6 +8,7 @@ import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
@ -15,7 +16,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
|
||||
@CommandParameters(description = "Temporarily bans a player for five minutes.", usage = "/<command> <username> [reason]", aliases = "noob")
|
||||
@CommandParameters(description = "Temporarily bans a player for five minutes.", usage = "/<command> [-q] <username> [reason]", aliases = "noob")
|
||||
public class Command_tban extends FreedomCommand
|
||||
{
|
||||
|
||||
@ -27,6 +28,17 @@ public class Command_tban extends FreedomCommand
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean quiet = args[0].equalsIgnoreCase("-q");
|
||||
if (quiet)
|
||||
{
|
||||
args = org.apache.commons.lang3.ArrayUtils.subarray(args, 1, args.length);
|
||||
|
||||
if (args.length < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
final String username;
|
||||
final List<String> ips = new ArrayList<>();
|
||||
|
||||
@ -49,27 +61,65 @@ public class Command_tban extends FreedomCommand
|
||||
final PlayerData entry = plugin.pl.getData(player);
|
||||
username = player.getName();
|
||||
ips.addAll(entry.getIps());
|
||||
|
||||
// Strike with lightning
|
||||
final Location targetPos = player.getLocation();
|
||||
for (int x = -1; x <= 1; x++)
|
||||
{
|
||||
for (int z = -1; z <= 1; z++)
|
||||
{
|
||||
final Location strike_pos = new Location(targetPos.getWorld(), targetPos.getBlockX() + x, targetPos.getBlockY(), targetPos.getBlockZ() + z);
|
||||
targetPos.getWorld().strikeLightning(strike_pos);
|
||||
}
|
||||
}
|
||||
|
||||
// Kill player
|
||||
player.setHealth(0.0);
|
||||
}
|
||||
|
||||
String reason = null;
|
||||
|
||||
if (player != null)
|
||||
if (args.length > 1)
|
||||
{
|
||||
FUtil.bcastMsg(sender.getName() + " - Tempbanning: " + player.getName() + " for 5 minutes", ChatColor.RED);
|
||||
reason = StringUtils.join(args, " ", 1, args.length);
|
||||
}
|
||||
|
||||
StringBuilder kick = new StringBuilder()
|
||||
.append(ChatColor.RED)
|
||||
.append("You have been temporarily banned for five minutes. Please read totalfreedom.me for more info.");
|
||||
|
||||
if (!quiet)
|
||||
{
|
||||
// Strike with lightning
|
||||
if (player != null)
|
||||
{
|
||||
final Location targetPos = player.getLocation();
|
||||
for (int x = -1; x <= 1; x++)
|
||||
{
|
||||
for (int z = -1; z <= 1; z++)
|
||||
{
|
||||
final Location strike_pos = new Location(targetPos.getWorld(), targetPos.getBlockX() + x, targetPos.getBlockY(), targetPos.getBlockZ() + z);
|
||||
targetPos.getWorld().strikeLightning(strike_pos);
|
||||
}
|
||||
}
|
||||
|
||||
// Kill player
|
||||
player.setHealth(0.0);
|
||||
|
||||
if (reason != null)
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Tempbanning " + player.getName() + " for 5 minutes - Reason: " + reason, true);
|
||||
kick.append("\n")
|
||||
.append(ChatColor.RED)
|
||||
.append("Reason: ")
|
||||
.append(ChatColor.GOLD)
|
||||
.append(reason);
|
||||
}
|
||||
else
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Tempbanning " + player.getName() + " for 5 minutes", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (player != null)
|
||||
{
|
||||
if (reason != null)
|
||||
{
|
||||
msg("Quietly temporarily banned " + player.getName() + " for 5 minutes.");
|
||||
kick.append("\n")
|
||||
.append(ChatColor.RED)
|
||||
.append("Reason: ")
|
||||
.append(ChatColor.GOLD)
|
||||
.append(reason);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Ban player
|
||||
@ -83,12 +133,11 @@ public class Command_tban extends FreedomCommand
|
||||
// Kick player
|
||||
if (player != null)
|
||||
{
|
||||
player.kickPlayer(ChatColor.RED + "You have been temporarily banned for five minutes. Please read totalfreedom.me for more info.");
|
||||
player.kickPlayer(kick.toString());
|
||||
}
|
||||
|
||||
// Log ban
|
||||
plugin.pul.logPunishment(new Punishment(username, ips.get(0), sender.getName(), PunishmentType.TEMPBAN, reason));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -18,7 +18,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Temporarily ban someone.", usage = "/<command> [playername] [duration] [reason]")
|
||||
@CommandParameters(description = "Temporarily ban someone.", usage = "/<command> [-q] <username> [duration] [reason]")
|
||||
public class Command_tempban extends FreedomCommand
|
||||
{
|
||||
|
||||
@ -32,6 +32,17 @@ public class Command_tempban extends FreedomCommand
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean quiet = args[0].equalsIgnoreCase("-q");
|
||||
if (quiet)
|
||||
{
|
||||
args = org.apache.commons.lang3.ArrayUtils.subarray(args, 1, args.length);
|
||||
|
||||
if (args.length < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
final String username;
|
||||
final List<String> ips = new ArrayList<>();
|
||||
|
||||
@ -55,6 +66,7 @@ public class Command_tempban extends FreedomCommand
|
||||
username = player.getName();
|
||||
ips.addAll(entry.getIps());
|
||||
}
|
||||
|
||||
final StringBuilder message = new StringBuilder("Temporarily banned " + player.getName());
|
||||
|
||||
Date expires = FUtil.parseDateOffset("30m");
|
||||
@ -72,18 +84,25 @@ public class Command_tempban extends FreedomCommand
|
||||
message.append(", Reason: \"").append(reason).append("\"");
|
||||
}
|
||||
|
||||
// strike with lightning effect:
|
||||
final Location targetPos = player.getLocation();
|
||||
for (int x = -1; x <= 1; x++)
|
||||
if (!quiet)
|
||||
{
|
||||
for (int z = -1; z <= 1; z++)
|
||||
// Strike with lightning
|
||||
final Location targetPos = player.getLocation();
|
||||
for (int x = -1; x <= 1; x++)
|
||||
{
|
||||
final Location strike_pos = new Location(targetPos.getWorld(), targetPos.getBlockX() + x, targetPos.getBlockY(), targetPos.getBlockZ() + z);
|
||||
targetPos.getWorld().strikeLightningEffect(strike_pos);
|
||||
for (int z = -1; z <= 1; z++)
|
||||
{
|
||||
final Location strike_pos = new Location(targetPos.getWorld(), targetPos.getBlockX() + x, targetPos.getBlockY(), targetPos.getBlockZ() + z);
|
||||
targetPos.getWorld().strikeLightningEffect(strike_pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FUtil.adminAction(sender.getName(), message.toString(), true);
|
||||
FUtil.adminAction(sender.getName(), message.toString(), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("Quietly temporarily banned " + player.getName() + ".");
|
||||
}
|
||||
|
||||
Ban ban = Ban.forPlayerName(username, sender, expires, reason);
|
||||
for (String ip : ips)
|
||||
@ -92,9 +111,7 @@ public class Command_tempban extends FreedomCommand
|
||||
}
|
||||
plugin.bm.addBan(ban);
|
||||
player.kickPlayer(ban.bakeKickMessage());
|
||||
|
||||
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.TEMPBAN, reason));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -9,33 +9,40 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Warns the specified player.", usage = "/<command> <player> <reason>")
|
||||
@CommandParameters(description = "Warns the specified player.", usage = "/<command> [-q] <player> <reason>")
|
||||
public class Command_warn extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length < 2)
|
||||
if (args.length == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Player player = getPlayer(args[0]);
|
||||
boolean quiet = args[0].equalsIgnoreCase("-q");
|
||||
if (quiet)
|
||||
{
|
||||
args = org.apache.commons.lang3.ArrayUtils.subarray(args, 1, args.length);
|
||||
|
||||
if (args.length < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Player player = getPlayer(args[0]);
|
||||
if (player == null)
|
||||
{
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sender instanceof Player)
|
||||
if (playerSender == player)
|
||||
{
|
||||
if (player.equals(playerSender))
|
||||
{
|
||||
msg(ChatColor.RED + "Please, don't try to warn yourself.");
|
||||
return true;
|
||||
}
|
||||
msg(ChatColor.RED + "Please, don't try to warn yourself.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (plugin.al.isAdmin(player))
|
||||
@ -45,23 +52,26 @@ public class Command_warn extends FreedomCommand
|
||||
}
|
||||
|
||||
String warnReason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
|
||||
|
||||
msg(player, ChatColor.RED + "[WARNING] You received a warning from " + sender.getName() + ": " + warnReason);
|
||||
player.sendTitle(ChatColor.RED + "You've been warned.", ChatColor.YELLOW + "Reason: " + warnReason, 20, 100, 60);
|
||||
msg(ChatColor.GREEN + "You have successfully warned " + player.getName());
|
||||
final StringBuilder adminNotice = new StringBuilder()
|
||||
.append(ChatColor.RED)
|
||||
.append(sender.getName())
|
||||
.append(" - ")
|
||||
.append("Warning: ")
|
||||
.append(player.getName())
|
||||
.append(" - Reason: ")
|
||||
.append(ChatColor.YELLOW)
|
||||
.append(warnReason);
|
||||
plugin.al.messageAllAdmins(adminNotice.toString());
|
||||
|
||||
if (quiet)
|
||||
{
|
||||
msg("Warned " + player.getName() + " quietly");
|
||||
return true;
|
||||
}
|
||||
|
||||
msg(player, ChatColor.RED + "[WARNING] You received a warning from " + sender.getName() + ": " + warnReason);
|
||||
String adminNotice = ChatColor.RED +
|
||||
sender.getName() +
|
||||
" - " +
|
||||
"Warning: " +
|
||||
player.getName() +
|
||||
" - Reason: " +
|
||||
ChatColor.YELLOW +
|
||||
warnReason;
|
||||
plugin.al.messageAllAdmins(adminNotice);
|
||||
plugin.pl.getPlayer(player).incrementWarnings();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user