mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Added configurable blocked commands
This commit is contained in:
parent
1d9e6ae931
commit
44f72815e1
@ -1,5 +1,5 @@
|
|||||||
#Tue, 02 Jul 2013 19:01:31 -0400
|
#Thu, 04 Jul 2013 22:45:10 +0200
|
||||||
|
|
||||||
program.VERSION=2.20
|
program.VERSION=2.21
|
||||||
program.BUILDNUM=242
|
program.BUILDNUM=255
|
||||||
program.BUILDDATE=07/02/2013 07\:01 PM
|
program.BUILDDATE=07/04/2013 10\:45 PM
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
#Build Number for ANT. Do not edit!
|
#Build Number for ANT. Do not edit!
|
||||||
#Tue Jul 02 19:01:31 EDT 2013
|
#Thu Jul 04 22:45:10 CEST 2013
|
||||||
build.number=243
|
build.number=256
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# TotalFreedomMod v2.20 Configuration
|
# TotalFreedomMod v2.21 Configuration
|
||||||
# by Madgeek1450 and DarthSalamon
|
# by Madgeek1450 and DarthSalamon
|
||||||
|
|
||||||
# Block placement prevention:
|
# Block placement prevention:
|
||||||
@ -14,6 +14,63 @@ allow_tnt_minecarts: false
|
|||||||
allow_explosions: false
|
allow_explosions: false
|
||||||
explosiveRadius: 4.0
|
explosiveRadius: 4.0
|
||||||
|
|
||||||
|
# Blocked commands:
|
||||||
|
#
|
||||||
|
# How blocked commands work:
|
||||||
|
# All sections described below are delimited by colon-characters.
|
||||||
|
# Make sure that you block a command by it's main command name, not an alias
|
||||||
|
# -as all aliases are blocked by default. Commands are case-insensitive ofcourse.
|
||||||
|
# You can block specific subcommands aswell. eg: /mail sendall
|
||||||
|
#
|
||||||
|
# * The first section is a letter which indicates which rank may use this command
|
||||||
|
# Valid ranks:
|
||||||
|
# n - Nobody (Completely disabled)
|
||||||
|
# c - Senior Admins (Console)
|
||||||
|
# t - Telnet Admins (Console)
|
||||||
|
# s - SuperAdmins
|
||||||
|
# o - Ops (Non-Ops won't be able to use it)
|
||||||
|
#
|
||||||
|
# * The second section is a letter which indicates what to do when a player executes that command.
|
||||||
|
# Valid actions:
|
||||||
|
# b - Block the command
|
||||||
|
# a - Block the command and auto-eject that player (for ops and below)
|
||||||
|
# u - Block the command and Return an "Unknown command" message (Used to hide commands)
|
||||||
|
#
|
||||||
|
# * The third section is the command to be blocked, prefixed with a slash
|
||||||
|
#
|
||||||
|
# * The fourth section is the message to send to the player when executing that command.
|
||||||
|
# This should be ommited if unwanted. ChatColors are supported with the &-key. By default
|
||||||
|
# -the starting ChatColor is set to gray. You can use the default 'That command is blocked.' message
|
||||||
|
# by using a single underscore.
|
||||||
|
#
|
||||||
|
# Examples:
|
||||||
|
# - 'n:b:/mail sendall:&4You can't send mails to everyone!'
|
||||||
|
# - 's:a:/stop'
|
||||||
|
# - 'n:b:/ban:_'
|
||||||
|
#
|
||||||
|
blocked_commands:
|
||||||
|
# Disabled commands
|
||||||
|
- 'n:b:/time:Server-side time changing is disabled. Please use /ptime to set your own personal time.'
|
||||||
|
- 'n:b:/md:This server now uses DisguiseCraft instead of MobDisguise. Type /d to disguise and /u to undisguise.'
|
||||||
|
- 'n:b:/gamemode:Use /creative and /survival to set your gamemode.'
|
||||||
|
- 'n:b:/ban:_'
|
||||||
|
- 'n:b:/pardon:_'
|
||||||
|
- 'n:b:/toggledownfall:_'
|
||||||
|
|
||||||
|
# Superadmin commands
|
||||||
|
- 's:b:/kick:_'
|
||||||
|
- 's:b:/socialspy:_'
|
||||||
|
- 's:b:/kill:_'
|
||||||
|
- 's:a:/stop'
|
||||||
|
- 's:a:/reload'
|
||||||
|
- 's:a:/nuke'
|
||||||
|
- 's:a:/save-all'
|
||||||
|
- 's:a:/save-on'
|
||||||
|
- 's:a:/save-off'
|
||||||
|
- 's:a:/clearhistory'
|
||||||
|
- 's:a:/butcher'
|
||||||
|
- 's:a://butcher'
|
||||||
|
|
||||||
# Automatically wipe dropped objects:
|
# Automatically wipe dropped objects:
|
||||||
auto_wipe: true
|
auto_wipe: true
|
||||||
|
|
||||||
|
@ -6,7 +6,15 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import me.StevenLawson.TotalFreedomMod.*;
|
import me.StevenLawson.TotalFreedomMod.TFM_CommandBlocker;
|
||||||
|
import me.StevenLawson.TotalFreedomMod.TFM_LandmineData;
|
||||||
|
import me.StevenLawson.TotalFreedomMod.TFM_Log;
|
||||||
|
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
|
||||||
|
import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
|
||||||
|
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
|
||||||
|
import me.StevenLawson.TotalFreedomMod.TFM_UserList;
|
||||||
|
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||||
|
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -22,7 +30,17 @@ import org.bukkit.event.EventPriority;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
import org.bukkit.event.block.LeavesDecayEvent;
|
import org.bukkit.event.block.LeavesDecayEvent;
|
||||||
import org.bukkit.event.player.*;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||||
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.event.player.PlayerKickEvent;
|
||||||
|
import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
import org.bukkit.event.server.RemoteServerCommandEvent;
|
||||||
|
import org.bukkit.event.server.ServerCommandEvent;
|
||||||
import org.bukkit.event.server.ServerListPingEvent;
|
import org.bukkit.event.server.ServerListPingEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
@ -367,7 +385,7 @@ public class TFM_PlayerListener implements Listener
|
|||||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
|
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
|
||||||
playerdata.incrementMsgCount();
|
playerdata.incrementMsgCount();
|
||||||
|
|
||||||
// check for spam
|
// Check for spam
|
||||||
if (playerdata.getMsgCount() > 10)
|
if (playerdata.getMsgCount() > 10)
|
||||||
{
|
{
|
||||||
TFM_Util.bcastMsg(p.getName() + " was automatically kicked for spamming chat.", ChatColor.RED);
|
TFM_Util.bcastMsg(p.getName() + " was automatically kicked for spamming chat.", ChatColor.RED);
|
||||||
@ -379,7 +397,7 @@ public class TFM_PlayerListener implements Listener
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for message repeat
|
// Check for message repeat
|
||||||
if (playerdata.getLastMessage().equalsIgnoreCase(message))
|
if (playerdata.getLastMessage().equalsIgnoreCase(message))
|
||||||
{
|
{
|
||||||
TFM_Util.playerMsg(p, "Please do not repeat messages.");
|
TFM_Util.playerMsg(p, "Please do not repeat messages.");
|
||||||
@ -388,7 +406,7 @@ public class TFM_PlayerListener implements Listener
|
|||||||
}
|
}
|
||||||
playerdata.setLastMessage(message);
|
playerdata.setLastMessage(message);
|
||||||
|
|
||||||
// check for muted
|
// Check for muted
|
||||||
if (playerdata.isMuted())
|
if (playerdata.isMuted())
|
||||||
{
|
{
|
||||||
if (!TFM_SuperadminList.isUserSuperadmin(p))
|
if (!TFM_SuperadminList.isUserSuperadmin(p))
|
||||||
@ -403,17 +421,17 @@ public class TFM_PlayerListener implements Listener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// strip color from messages
|
// Strip color from messages
|
||||||
message = ChatColor.stripColor(message);
|
message = ChatColor.stripColor(message);
|
||||||
|
|
||||||
// truncate messages that are too long - 100 characters is vanilla client max
|
// Truncate messages that are too long - 100 characters is vanilla client max
|
||||||
if (message.length() > 100)
|
if (message.length() > 100)
|
||||||
{
|
{
|
||||||
message = message.substring(0, 100);
|
message = message.substring(0, 100);
|
||||||
TFM_Util.playerMsg(p, "Message was shortened because it was too long to send.");
|
TFM_Util.playerMsg(p, "Message was shortened because it was too long to send.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for caps - Quit messing with this :-/
|
// Check for caps
|
||||||
if (message.length() >= 6)
|
if (message.length() >= 6)
|
||||||
{
|
{
|
||||||
int caps = 0;
|
int caps = 0;
|
||||||
@ -430,7 +448,7 @@ public class TFM_PlayerListener implements Listener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for adminchat
|
// Check for adminchat
|
||||||
if (playerdata.inAdminChat())
|
if (playerdata.inAdminChat())
|
||||||
{
|
{
|
||||||
TFM_Util.adminChatMessage(p, message, false);
|
TFM_Util.adminChatMessage(p, message, false);
|
||||||
@ -438,7 +456,7 @@ public class TFM_PlayerListener implements Listener
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally, set message
|
// Finally, set message
|
||||||
event.setMessage(message);
|
event.setMessage(message);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -455,6 +473,7 @@ public class TFM_PlayerListener implements Listener
|
|||||||
|
|
||||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
|
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
|
||||||
playerdata.incrementMsgCount();
|
playerdata.incrementMsgCount();
|
||||||
|
playerdata.setLastCommand(command);
|
||||||
|
|
||||||
if (playerdata.getMsgCount() > 10)
|
if (playerdata.getMsgCount() > 10)
|
||||||
{
|
{
|
||||||
@ -476,144 +495,14 @@ public class TFM_PlayerListener implements Listener
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TotalFreedomMod.preprocessLogEnabled)
|
// Block commands if player is muted
|
||||||
{
|
|
||||||
TFM_Log.info(String.format("[PREPROCESS_COMMAND] %s(%s): %s", p.getName(), ChatColor.stripColor(p.getDisplayName()), command), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
playerdata.setLastCommand(command);
|
|
||||||
|
|
||||||
command = command.toLowerCase().trim();
|
|
||||||
|
|
||||||
boolean block_command = false;
|
|
||||||
|
|
||||||
//Commands that will auto-kick the user:
|
|
||||||
if (Pattern.compile("^/stop").matcher(command).find())
|
|
||||||
{
|
|
||||||
if (!TFM_SuperadminList.isUserSuperadmin(p))
|
|
||||||
{
|
|
||||||
block_command = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (Pattern.compile("^/reload").matcher(command).find())
|
|
||||||
{
|
|
||||||
if (!TFM_SuperadminList.isUserSuperadmin(p))
|
|
||||||
{
|
|
||||||
block_command = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (Pattern.compile("^/nuke").matcher(command).find())
|
|
||||||
{
|
|
||||||
if (!TFM_SuperadminList.isUserSuperadmin(p))
|
|
||||||
{
|
|
||||||
block_command = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (Pattern.compile("^/rl").matcher(command).find())
|
|
||||||
{
|
|
||||||
if (!TFM_SuperadminList.isUserSuperadmin(p))
|
|
||||||
{
|
|
||||||
block_command = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (Pattern.compile("^/save-").matcher(command).find())
|
|
||||||
{
|
|
||||||
if (!TFM_SuperadminList.isUserSuperadmin(p))
|
|
||||||
{
|
|
||||||
block_command = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (Pattern.compile("^/clearhistory").matcher(command).find())
|
|
||||||
{
|
|
||||||
if (!TFM_SuperadminList.isUserSuperadmin(p))
|
|
||||||
{
|
|
||||||
block_command = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (Pattern.compile("^//?butcher").matcher(command).find())
|
|
||||||
{
|
|
||||||
if (!TFM_SuperadminList.isUserSuperadmin(p))
|
|
||||||
{
|
|
||||||
block_command = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (block_command)
|
|
||||||
{
|
|
||||||
TFM_Util.autoEject(p, "You used a prohibited command: " + command);
|
|
||||||
TFM_Util.bcastMsg(p.getName() + " was automatically kicked for using harmful commands.", ChatColor.RED);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// commands that will not auto-kick the user, but still deny:
|
|
||||||
if (Pattern.compile("^/time").matcher(command).find())
|
|
||||||
{
|
|
||||||
p.sendMessage(ChatColor.GRAY + "Server-side time changing is disabled. Please use /ptime to set your own personal time.");
|
|
||||||
block_command = true;
|
|
||||||
}
|
|
||||||
else if (Pattern.compile("^/md").matcher(command).find())
|
|
||||||
{
|
|
||||||
p.sendMessage(ChatColor.GRAY + "This server now uses DisguiseCraft instead of MobDisguise. Type /d to disguise and /u to undisguise.");
|
|
||||||
block_command = true;
|
|
||||||
}
|
|
||||||
else if (Pattern.compile("^/gamemode").matcher(command).find())
|
|
||||||
{
|
|
||||||
p.sendMessage(ChatColor.GRAY + "Use /creative and /survival to set your gamemode.");
|
|
||||||
block_command = true;
|
|
||||||
}
|
|
||||||
else if (Pattern.compile("^/ban").matcher(command).find())
|
|
||||||
{
|
|
||||||
if (!Pattern.compile("^/banlist").matcher(command).find())
|
|
||||||
{
|
|
||||||
block_command = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (Pattern.compile("^/kick").matcher(command).find())
|
|
||||||
{
|
|
||||||
if (!TFM_SuperadminList.isUserSuperadmin(p))
|
|
||||||
{
|
|
||||||
block_command = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (Pattern.compile("^/kill").matcher(command).find())
|
|
||||||
{
|
|
||||||
if (!TFM_SuperadminList.isUserSuperadmin(p))
|
|
||||||
{
|
|
||||||
block_command = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (Pattern.compile("^/socialspy").matcher(command).find())
|
|
||||||
{
|
|
||||||
if (!TFM_SuperadminList.isUserSuperadmin(p))
|
|
||||||
{
|
|
||||||
block_command = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (Pattern.compile("^/pardon").matcher(command).find())
|
|
||||||
{
|
|
||||||
block_command = true;
|
|
||||||
}
|
|
||||||
else if (Pattern.compile("^/toggledownfall").matcher(command).find())
|
|
||||||
{
|
|
||||||
block_command = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (block_command)
|
|
||||||
{
|
|
||||||
p.sendMessage(ChatColor.GRAY + "That command is blocked.");
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// block commands while player is muted
|
|
||||||
if (playerdata.isMuted())
|
if (playerdata.isMuted())
|
||||||
{
|
{
|
||||||
if (!TFM_SuperadminList.isUserSuperadmin(p))
|
if (!TFM_SuperadminList.isUserSuperadmin(p))
|
||||||
{
|
{
|
||||||
for (String test_command : BLOCKED_MUTED_CMDS)
|
for (String test_command : BLOCKED_MUTED_CMDS)
|
||||||
{
|
{
|
||||||
if (Pattern.compile("^/" + test_command.toLowerCase() + " ").matcher(command.toLowerCase()).find())
|
if (Pattern.compile("^/" + test_command.toLowerCase() + " ").matcher(command).find())
|
||||||
{
|
{
|
||||||
p.sendMessage(ChatColor.RED + "That command is blocked while you are muted.");
|
p.sendMessage(ChatColor.RED + "That command is blocked while you are muted.");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -625,7 +514,20 @@ public class TFM_PlayerListener implements Listener
|
|||||||
{
|
{
|
||||||
playerdata.setMuted(false);
|
playerdata.setMuted(false);
|
||||||
}
|
}
|
||||||
return;
|
}
|
||||||
|
|
||||||
|
if (TotalFreedomMod.preprocessLogEnabled)
|
||||||
|
{
|
||||||
|
TFM_Log.info(String.format("[PREPROCESS_COMMAND] %s(%s): %s", p.getName(), ChatColor.stripColor(p.getDisplayName()), command), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
command = command.toLowerCase().trim();
|
||||||
|
|
||||||
|
// Blocked commands
|
||||||
|
if (TFM_CommandBlocker.isCommandBlocked(command, event.getPlayer()))
|
||||||
|
{
|
||||||
|
// CommandBlocker handles messages and broadcasts
|
||||||
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!TFM_SuperadminList.isUserSuperadmin(p))
|
if (!TFM_SuperadminList.isUserSuperadmin(p))
|
||||||
@ -640,6 +542,24 @@ public class TFM_PlayerListener implements Listener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
|
public void onRemoteServerCommand(RemoteServerCommandEvent event)
|
||||||
|
{
|
||||||
|
if (TFM_CommandBlocker.isCommandBlocked("/" + event.getCommand(), event.getSender()))
|
||||||
|
{
|
||||||
|
event.setCommand("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
|
public void onServerCommand(ServerCommandEvent event)
|
||||||
|
{
|
||||||
|
if (TFM_CommandBlocker.isCommandBlocked("/" + event.getCommand(), event.getSender()))
|
||||||
|
{
|
||||||
|
event.setCommand("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPlayerDropItem(PlayerDropItemEvent event)
|
public void onPlayerDropItem(PlayerDropItemEvent event)
|
||||||
{
|
{
|
||||||
@ -766,6 +686,7 @@ public class TFM_PlayerListener implements Listener
|
|||||||
{
|
{
|
||||||
event.setMotd(ChatColor.RED + "You are banned!");
|
event.setMotd(ChatColor.RED + "You are banned!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TotalFreedomMod.adminOnlyMode)
|
if (TotalFreedomMod.adminOnlyMode)
|
||||||
{
|
{
|
||||||
event.setMotd(ChatColor.RED + "Server in AdminMode!");
|
event.setMotd(ChatColor.RED + "Server in AdminMode!");
|
||||||
|
144
src/me/StevenLawson/TotalFreedomMod/TFM_CommandBlocker.java
Normal file
144
src/me/StevenLawson/TotalFreedomMod/TFM_CommandBlocker.java
Normal file
@ -0,0 +1,144 @@
|
|||||||
|
package me.StevenLawson.TotalFreedomMod;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.server.RemoteServerCommandEvent;
|
||||||
|
|
||||||
|
|
||||||
|
public class TFM_CommandBlocker
|
||||||
|
{
|
||||||
|
|
||||||
|
public static boolean isCommandBlocked(String command, CommandSender sender)
|
||||||
|
{
|
||||||
|
String name = sender.getName();
|
||||||
|
command = command.toLowerCase().trim();
|
||||||
|
|
||||||
|
for (String blocked_command : TotalFreedomMod.blockedCommands)
|
||||||
|
{
|
||||||
|
String[] parts = blocked_command.split(":");
|
||||||
|
if (parts.length < 3 || parts.length > 4)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(command + " ").startsWith(parts[2] + " "))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SenderRank.hasPermissions(sender, parts[0]))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Past this line indicates that the command is blocked.
|
||||||
|
|
||||||
|
// Optional: Send a message
|
||||||
|
if (parts.length == 4)
|
||||||
|
{
|
||||||
|
if ("_".equals(parts[3]))
|
||||||
|
{
|
||||||
|
sender.sendMessage(ChatColor.GRAY + "That command is blocked.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sender.sendMessage(ChatColor.GRAY + ChatColor.translateAlternateColorCodes('&', parts[3]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TFM_Log.info("Player Rank: " + SenderRank.getSenderRank(sender).rank);
|
||||||
|
|
||||||
|
// Action
|
||||||
|
if ("b".equals(parts[1]))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if ("a".equals(parts[1]))
|
||||||
|
{
|
||||||
|
if (SenderRank.getSenderRank(sender).rank < 2) // Only auto-eject Ops and non-ops
|
||||||
|
{
|
||||||
|
TFM_Util.autoEject((Player) sender, "You used a prohibited command: " + command);
|
||||||
|
TFM_Util.bcastMsg(name + " was automatically kicked for using harmful commands.", ChatColor.RED);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if ("u".equals(parts[1]))
|
||||||
|
{
|
||||||
|
sender.sendMessage("Unknown command. Type \"help\" for help.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum SenderRank
|
||||||
|
{
|
||||||
|
ANYONE("a", 0),
|
||||||
|
OP("o", 1),
|
||||||
|
SUPER("s", 2),
|
||||||
|
TELNET("t", 3),
|
||||||
|
SENIOR("c", 4),
|
||||||
|
NOBODY("n", 5);
|
||||||
|
|
||||||
|
private String letter = "n";
|
||||||
|
private int rank = 5;
|
||||||
|
|
||||||
|
SenderRank(String letter, int rank)
|
||||||
|
{
|
||||||
|
this.letter = letter;
|
||||||
|
this.rank = rank;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean hasPermissions(CommandSender sender, String letter)
|
||||||
|
{
|
||||||
|
return (getSenderRank(sender).rank >= getSenderRankByLetter(letter).rank);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SenderRank getSenderRank(CommandSender sender)
|
||||||
|
{
|
||||||
|
if (!(sender instanceof Player))
|
||||||
|
{
|
||||||
|
if (TFM_SuperadminList.isSeniorAdmin(sender))
|
||||||
|
{
|
||||||
|
return SenderRank.SENIOR;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return SenderRank.TELNET;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TFM_SuperadminList.isUserSuperadmin(sender))
|
||||||
|
{
|
||||||
|
return SenderRank.SUPER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sender.isOp())
|
||||||
|
{
|
||||||
|
return SenderRank.OP;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SenderRank.ANYONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SenderRank getSenderRankByLetter(String letter)
|
||||||
|
{
|
||||||
|
for (SenderRank rank : SenderRank.values())
|
||||||
|
{
|
||||||
|
if (letter.equals(rank.letter))
|
||||||
|
{
|
||||||
|
return rank;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return SenderRank.NOBODY;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -211,6 +211,7 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
public static boolean allowFliudSpread = false;
|
public static boolean allowFliudSpread = false;
|
||||||
public static boolean allowTntMinecarts = false;
|
public static boolean allowTntMinecarts = false;
|
||||||
public static double explosiveRadius = 4.0D;
|
public static double explosiveRadius = 4.0D;
|
||||||
|
public static List<String> blockedCommands = new ArrayList<String>();
|
||||||
public static boolean autoEntityWipe = true;
|
public static boolean autoEntityWipe = true;
|
||||||
public static boolean nukeMonitor = true;
|
public static boolean nukeMonitor = true;
|
||||||
public static int nukeMonitorCountBreak = 100;
|
public static int nukeMonitorCountBreak = 100;
|
||||||
@ -255,6 +256,7 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
allowExplosions = config.getBoolean("allow_explosions", allowExplosions);
|
allowExplosions = config.getBoolean("allow_explosions", allowExplosions);
|
||||||
allowTntMinecarts = config.getBoolean("allow_tnt_minecarts", allowTntMinecarts);
|
allowTntMinecarts = config.getBoolean("allow_tnt_minecarts", allowTntMinecarts);
|
||||||
explosiveRadius = config.getDouble("explosiveRadius", explosiveRadius);
|
explosiveRadius = config.getDouble("explosiveRadius", explosiveRadius);
|
||||||
|
blockedCommands = config.getStringList("blocked_commands");
|
||||||
autoEntityWipe = config.getBoolean("auto_wipe", autoEntityWipe);
|
autoEntityWipe = config.getBoolean("auto_wipe", autoEntityWipe);
|
||||||
nukeMonitor = config.getBoolean("nuke_monitor", nukeMonitor);
|
nukeMonitor = config.getBoolean("nuke_monitor", nukeMonitor);
|
||||||
nukeMonitorCountBreak = config.getInt("nuke_monitor_count_break", nukeMonitorCountBreak);
|
nukeMonitorCountBreak = config.getInt("nuke_monitor_count_break", nukeMonitorCountBreak);
|
||||||
@ -281,9 +283,9 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
autoProtectSpawnpoints = config.getBoolean("auto_protect_spawnpoints", autoProtectSpawnpoints);
|
autoProtectSpawnpoints = config.getBoolean("auto_protect_spawnpoints", autoProtectSpawnpoints);
|
||||||
autoProtectRadius = config.getDouble("auto_protect_radius", autoProtectRadius);
|
autoProtectRadius = config.getDouble("auto_protect_radius", autoProtectRadius);
|
||||||
host_sender_names = config.getStringList("host_sender_names");
|
host_sender_names = config.getStringList("host_sender_names");
|
||||||
twitterbotEnabled = config.getBoolean("twitterbot_enabled");
|
twitterbotEnabled = config.getBoolean("twitterbot_enabled", twitterbotEnabled);
|
||||||
twitterbotUrl = config.getString("twitterbot_url");
|
twitterbotUrl = config.getString("twitterbot_url", twitterbotUrl);
|
||||||
twitterbotSecret = config.getString("twitterbot_secret");
|
twitterbotSecret = config.getString("twitterbot_secret", twitterbotSecret);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
name: TotalFreedomMod
|
name: TotalFreedomMod
|
||||||
main: me.StevenLawson.TotalFreedomMod.TotalFreedomMod
|
main: me.StevenLawson.TotalFreedomMod.TotalFreedomMod
|
||||||
version: 2.20
|
version: 2.21
|
||||||
description: Plugin for the Total Freedom server.
|
description: Plugin for the Total Freedom server.
|
||||||
authors: [StevenLawson / Madgeek1450, JeromSar / DarthSalamon]
|
authors: [StevenLawson / Madgeek1450, JeromSar / DarthSalamon]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user