A few of Darth's recent dev branch changes.

-Made it so only superadmins can use qop and qdeop
-Reformat of mute/stfu, now blocks essentials based communication commands as well as /say when someone is muted.
-Blocked socialspy.
This commit is contained in:
Steven Lawson 2012-11-21 22:42:05 -05:00
parent 892682e969
commit ed82272f5c
5 changed files with 75 additions and 35 deletions

View File

@ -1,5 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.command.Command;
@ -16,7 +17,7 @@ public class Command_qdeop extends TFM_Command
return false;
}
if (!(senderIsConsole || sender.isOp()))
if (!(senderIsConsole || TFM_SuperadminList.isUserSuperadmin(sender)))
{
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
return true;

View File

@ -1,5 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.command.Command;
@ -16,7 +17,7 @@ public class Command_qop extends TFM_Command
return false;
}
if (!(senderIsConsole || sender.isOp()))
if (!(senderIsConsole || TFM_SuperadminList.isUserSuperadmin(sender)))
{
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
return true;

View File

@ -9,7 +9,6 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
//This command was coded initially by JeromSar
public class Command_stfu extends TFM_Command
{
@Override
@ -44,10 +43,8 @@ public class Command_stfu extends TFM_Command
{
TFM_Util.playerMsg(sender, "- none");
}
return true;
}
if (args[0].equalsIgnoreCase("purge"))
else if (args[0].equalsIgnoreCase("purge"))
{
TFM_Util.adminAction(sender.getName(), "Unmuting all players.", true);
TFM_UserInfo info;
@ -62,10 +59,8 @@ public class Command_stfu extends TFM_Command
}
}
TFM_Util.playerMsg(sender, "Unmuted " + count + " players.");
return true;
}
if (args[0].equalsIgnoreCase("all"))
else if (args[0].equalsIgnoreCase("all"))
{
TFM_Util.adminAction(sender.getName(), "Muting all non-Superadmins", true);
@ -82,9 +77,9 @@ public class Command_stfu extends TFM_Command
}
TFM_Util.playerMsg(sender, "Muted " + counter + " players.");
return true;
}
else
{
Player p;
try
{
@ -104,11 +99,19 @@ public class Command_stfu extends TFM_Command
TFM_Util.playerMsg(sender, "Unmuted " + p.getName());
}
else
{
if (!TFM_SuperadminList.isUserSuperadmin(p))
{
TFM_Util.adminAction(sender.getName(), "Muting " + p.getName(), true);
playerdata.setMuted(true);
TFM_Util.playerMsg(sender, "Muted " + p.getName());
}
else
{
TFM_Util.playerMsg(sender, p.getName() + " is a superadmin, and can't be muted.");
}
}
}
return true;
}

View File

@ -1,7 +1,9 @@
package me.StevenLawson.TotalFreedomMod.Listener;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.regex.Pattern;
import me.StevenLawson.TotalFreedomMod.*;
@ -9,7 +11,12 @@ import net.minecraft.server.BanEntry;
import net.minecraft.server.BanList;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.ServerConfigurationManagerAbstract;
import org.bukkit.*;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.block.Block;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -26,6 +33,7 @@ import org.bukkit.util.Vector;
public class TFM_PlayerListener implements Listener
{
private static final SimpleDateFormat date_format = new SimpleDateFormat("yyyy-MM-dd \'at\' HH:mm:ss z");
private static final List<String> BLOCKED_MUTED_CMDS = Arrays.asList(StringUtils.split("say,me,msg,m,tell,r,reply", ","));
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerInteract(PlayerInteractEvent event)
@ -99,7 +107,7 @@ public class TFM_PlayerListener implements Listener
}
case BLAZE_ROD:
{
if (TotalFreedomMod.allowExplosions && (player.getName().equals("Madgeek1450") || player.getName().equals("markbyron")))
if (TotalFreedomMod.allowExplosions && TFM_SuperadminList.isSeniorAdmin(player))
{
Block target_block = null;
@ -449,6 +457,13 @@ public class TFM_PlayerListener implements Listener
block_command = true;
}
}
else if (Pattern.compile("^/e?socialspy").matcher(command).find())
{
if (!TFM_SuperadminList.isUserSuperadmin(p))
{
block_command = true;
}
}
else if (Pattern.compile("^/pardon").matcher(command).find())
{
block_command = true;
@ -465,6 +480,26 @@ public class TFM_PlayerListener implements Listener
event.setCancelled(true);
return;
}
if (playerdata.isMuted())
{
if (!TFM_SuperadminList.isUserSuperadmin(p))
{
for (String test_command : BLOCKED_MUTED_CMDS)
{
if (Pattern.compile("^/" + test_command.toLowerCase() + " ").matcher(command.toLowerCase()).find())
{
p.sendMessage(ChatColor.RED + "That command is blocked while you are muted.");
event.setCancelled(true);
return;
}
}
}
else
{
playerdata.setMuted(false);
}
}
}
@EventHandler(priority = EventPriority.NORMAL)

View File

@ -19,7 +19,7 @@ superadmins:
is_senior_admin: true
console_aliases:
- madgeek
is_activated: false
is_activated: true
markbyron:
ips:
- 74.125.224.72