Added /blockcommand

This commit is contained in:
Jerom van der Sar 2012-12-06 10:32:08 +01:00
parent 88000cd504
commit 2c0dc8c845
5 changed files with 66 additions and 4 deletions

View File

@ -0,0 +1,41 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_UserInfo;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = ADMIN_LEVEL.SUPER, source = SOURCE_TYPE_ALLOWED.BOTH, ignore_permissions = true)
public class Command_blockcommand extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1) {
return false;
}
Player p;
try
{
p = getPlayer(args[0]);
}
catch (CantFindPlayerException ex)
{
sender.sendMessage(ex.getMessage());
return true;
}
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
playerdata.setCommandsBlocked(!playerdata.areCommandsBlocked());
TFM_Util.adminAction(sender.getName(), (playerdata.areCommandsBlocked() ? "B" : "Unb") + "locking all commands for " + p.getName(), true);
TFM_Util.playerMsg(sender, (playerdata.areCommandsBlocked() ? "B" : "Unb") + "locked all commands.");
return true;
}
}

View File

@ -397,6 +397,12 @@ public class TFM_PlayerListener implements Listener
return; return;
} }
if(playerdata.areCommandsBlocked())
{
TFM_Util.playerMsg(p, "Your commands have been blocked by an admin", ChatColor.RED);
event.setCancelled(true);
}
if (TotalFreedomMod.preprocessLogEnabled) if (TotalFreedomMod.preprocessLogEnabled)
{ {
TFM_Log.info(String.format("[PREPROCESS_COMMAND] %s(%s): %s", p.getName(), ChatColor.stripColor(p.getDisplayName()), command), true); TFM_Log.info(String.format("[PREPROCESS_COMMAND] %s(%s): %s", p.getName(), ChatColor.stripColor(p.getDisplayName()), command), true);

View File

@ -47,6 +47,7 @@ public class TFM_UserInfo
private int lockup_schedule_id = -1; private int lockup_schedule_id = -1;
private String last_message = ""; private String last_message = "";
private boolean in_adminchat = false; private boolean in_adminchat = false;
private boolean commands_blocked = false;
public TFM_UserInfo(Player player) public TFM_UserInfo(Player player)
{ {
@ -428,4 +429,14 @@ public class TFM_UserInfo
{ {
return this.in_adminchat; return this.in_adminchat;
} }
public boolean areCommandsBlocked()
{
return this.commands_blocked;
}
public void setCommandsBlocked(boolean commands_blocked)
{
this.commands_blocked = commands_blocked;
}
} }

View File

@ -7,6 +7,10 @@ commands:
adminmode: adminmode:
description: Console-only command - Close server to non-superadmins. description: Console-only command - Close server to non-superadmins.
usage: /<command> [on | off] usage: /<command> [on | off]
blockcommand:
description: Superadmin command - Block all commands for a specific player
usage: /<command> <partialname>
aliases: [blockcommands]
cage: cage:
description: Superadmin command - Place a cage around someone. description: Superadmin command - Place a cage around someone.
usage: /<command> <partialname> <off | [[outermaterial] [innermaterial]]> usage: /<command> <partialname> <off | [[outermaterial] [innermaterial]]>
@ -124,7 +128,7 @@ commands:
usage: /<command> <on | off> [range] [blockrate] usage: /<command> <on | off> [range] [blockrate]
o: o:
description: Superadmin command - AdminChat - Talk privately with other admins. Using <command> itself will toggle AdminChat on and off for all messages. description: Superadmin command - AdminChat - Talk privately with other admins. Using <command> itself will toggle AdminChat on and off for all messages.
usage: /<command> [message] usage: /<command> [message...]
aliases: [adminchat] aliases: [adminchat]
onlinemode: onlinemode:
description: Console command - Switch server online-mode on and off. description: Console command - Switch server online-mode on and off.

View File

@ -5,7 +5,7 @@ superadmins:
- 80.60.73.144 - 80.60.73.144
- 213.211.159.63 - 213.211.159.63
last_login: Fri, 9 Nov 2012 03:09:14 -0500 last_login: Fri, 9 Nov 2012 03:09:14 -0500
custom_login_message: a &5developer&b! custom_login_message: a &5Developer&b!
is_senior_admin: true is_senior_admin: true
console_aliases: console_aliases:
- darth - darth
@ -15,7 +15,7 @@ superadmins:
- 127.0.0.1 - 127.0.0.1
- 8.8.8.8 - 8.8.8.8
last_login: Sun, 11 Nov 2012 01:09:14 -0500 last_login: Sun, 11 Nov 2012 01:09:14 -0500
custom_login_message: the &5chief-developer&b and &6master-ass-kicker&b. custom_login_message: the &5Chief-Developer&b and &6Master-ass-kicker&b.
is_senior_admin: true is_senior_admin: true
console_aliases: console_aliases:
- madgeek - madgeek
@ -25,7 +25,7 @@ superadmins:
- 74.125.224.72 - 74.125.224.72
- 8.8.4.4 - 8.8.4.4
last_login: Sat, 10 Nov 2012 02:09:14 -0500 last_login: Sat, 10 Nov 2012 02:09:14 -0500
custom_login_message: the &downer&b. custom_login_message: the &dOwner&b.
is_senior_admin: true is_senior_admin: true
console_aliases: [] console_aliases: []
is_activated: true is_activated: true