on request: added feature to define telnet users who may use certain high-profile commands

This commit is contained in:
Jerom van der Sar 2012-09-30 15:51:07 +02:00
parent d0569c0243
commit e7f2ad893c
4 changed files with 38 additions and 16 deletions

View File

@ -53,3 +53,12 @@ flatlands_generation_params: 16,stone,32,dirt,1,grass
# Admin-Only Mode # Admin-Only Mode
admin_only_mode: false admin_only_mode: false
# SuperUsers; telnet users who have the permissions for certain high-profile commands (/doom, /lockup, ect)
superuser_names:
- markbyron
- mark
- madgeek1450
- madgeek
- darthsalamon
- darth

View File

@ -1,7 +1,5 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.Arrays;
import java.util.List;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -12,18 +10,10 @@ import org.bukkit.entity.Player;
public class Command_doom extends TFM_Command public class Command_doom extends TFM_Command
{ {
public final static List<String> ALLOWED_USERS = Arrays.asList(
"madgeek",
"darth",
"madgeek1450",
"mark",
"markbyron",
"darthsalamon");
@Override @Override
public boolean run(final CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) public boolean run(final CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{ {
if (!(senderIsConsole && ALLOWED_USERS.contains(sender.getName().toLowerCase()))) if (!(senderIsConsole && TotalFreedomMod.superUsers.contains(sender.getName().toLowerCase())))
{ {
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS); sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
return true; return true;

View File

@ -2,6 +2,7 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.Random; import java.util.Random;
import me.StevenLawson.TotalFreedomMod.TFM_UserInfo; import me.StevenLawson.TotalFreedomMod.TFM_UserInfo;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
@ -15,7 +16,7 @@ public class Command_lockup extends TFM_Command
@Override @Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{ {
if (!senderIsConsole) if (!(senderIsConsole && TotalFreedomMod.superUsers.contains(sender.getName().toLowerCase())))
{ {
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS); sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
return true; return true;
@ -25,19 +26,22 @@ public class Command_lockup extends TFM_Command
{ {
if (args[0].equalsIgnoreCase("all")) if (args[0].equalsIgnoreCase("all"))
{ {
TFM_Util.adminAction(sender.getName(), "Locking up all players", true);
for (Player p : server.getOnlinePlayers()) for (Player p : server.getOnlinePlayers())
{ {
startLockup(p); startLockup(p);
} }
sender.sendMessage(ChatColor.GRAY + "Locking up all players."); TFM_Util.playerMsg(sender, "Locked up all players.");
} }
else if (args[0].equalsIgnoreCase("purge")) else if (args[0].equalsIgnoreCase("purge"))
{ {
TFM_Util.adminAction(sender.getName(), "Unlocking all players", true);
for (Player p : server.getOnlinePlayers()) for (Player p : server.getOnlinePlayers())
{ {
cancelLockup(p); cancelLockup(p);
} }
sender.sendMessage(ChatColor.GRAY + "Not locking up all players."); TFM_Util.playerMsg(sender, "Unlocked all players.");
} }
else else
{ {
@ -59,8 +63,9 @@ public class Command_lockup extends TFM_Command
return true; return true;
} }
TFM_Util.adminAction(sender.getName(), "Locking up " + p.getName(), true);
startLockup(p); startLockup(p);
sender.sendMessage(ChatColor.GRAY + "Locking up " + p.getName()); TFM_Util.playerMsg(sender, "Locked up " + p.getName() + ".");
} }
else if (args[1].equalsIgnoreCase("off")) else if (args[1].equalsIgnoreCase("off"))
{ {
@ -75,8 +80,9 @@ public class Command_lockup extends TFM_Command
return true; return true;
} }
TFM_Util.adminAction(sender.getName(), "Unlocking " + p.getName(), true);
cancelLockup(p); cancelLockup(p);
sender.sendMessage(ChatColor.GRAY + "Not locking up " + p.getName() + " anymore."); TFM_Util.playerMsg(sender, "Unlocked " + p.getName() + ".");
} }
else else
{ {

View File

@ -3,12 +3,15 @@ package me.StevenLawson.TotalFreedomMod;
import java.io.File; import java.io.File;
import java.io.InputStream; import java.io.InputStream;
import java.util.*; import java.util.*;
import me.StevenLawson.TotalFreedomMod.Commands.TFM_Command; import me.StevenLawson.TotalFreedomMod.Commands.TFM_Command;
import me.StevenLawson.TotalFreedomMod.Listener.TFM_BlockListener; import me.StevenLawson.TotalFreedomMod.Listener.TFM_BlockListener;
import me.StevenLawson.TotalFreedomMod.Listener.TFM_EntityListener; import me.StevenLawson.TotalFreedomMod.Listener.TFM_EntityListener;
import me.StevenLawson.TotalFreedomMod.Listener.TFM_PlayerListener; import me.StevenLawson.TotalFreedomMod.Listener.TFM_PlayerListener;
import me.StevenLawson.TotalFreedomMod.Listener.TFM_WeatherListener; import me.StevenLawson.TotalFreedomMod.Listener.TFM_WeatherListener;
import org.apache.commons.lang.exception.ExceptionUtils; import org.apache.commons.lang.exception.ExceptionUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Server; import org.bukkit.Server;
@ -185,11 +188,24 @@ public class TotalFreedomMod extends JavaPlugin
public static String flatlandsGenerationParams = "16,stone,32,dirt,1,grass"; public static String flatlandsGenerationParams = "16,stone,32,dirt,1,grass";
public static boolean allowFliudSpread = false; public static boolean allowFliudSpread = false;
public static boolean adminOnlyMode = false; public static boolean adminOnlyMode = false;
public static String[] tempArray =
{
"markbyron",
"mark",
"madgeek1450",
"madgeek",
"darthsalamon",
"darth"
};
public static List<String> superUsers = Arrays.asList(tempArray);
public void loadMainConfig() public void loadMainConfig()
{ {
try try
{ {
tempArray = null;
TFM_Util.createDefaultConfiguration(CONFIG_FILE, getFile()); TFM_Util.createDefaultConfiguration(CONFIG_FILE, getFile());
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(getDataFolder(), CONFIG_FILE)); FileConfiguration config = YamlConfiguration.loadConfiguration(new File(getDataFolder(), CONFIG_FILE));
@ -222,6 +238,7 @@ public class TotalFreedomMod extends JavaPlugin
flatlandsGenerationParams = config.getString("flatlands_generation_params", flatlandsGenerationParams); flatlandsGenerationParams = config.getString("flatlands_generation_params", flatlandsGenerationParams);
allowFliudSpread = config.getBoolean("allow_fluid_spread", allowFliudSpread); allowFliudSpread = config.getBoolean("allow_fluid_spread", allowFliudSpread);
adminOnlyMode = config.getBoolean("admin_only_mode", adminOnlyMode); adminOnlyMode = config.getBoolean("admin_only_mode", adminOnlyMode);
superUsers = config.getStringList("superuser_names");
} }
catch (Exception ex) catch (Exception ex)
{ {