plugin.yml cleanup, going to do a better job of this later on (have it auto-generate the description, usage, and alias from the @CommandPermissions).

Cleanup TFM main class.
Added /listsync for associate servers.
Added config.yml based host_sender_names list.
This commit is contained in:
Steven Lawson 2012-12-02 12:05:54 -05:00
parent 4de09696b9
commit f7393a85c4
21 changed files with 110 additions and 68 deletions

View file

@ -58,3 +58,9 @@ admin_only_mode: false
protected_areas_enabled: true
auto_protect_spawnpoints: true
auto_protect_radius: 25.0
# Host Sender Names - Names that indicate automated services or host-based consoles you want to block from using some commands.
# Make sure these are all lower-case.
host_sender_names:
- rcon
- remotebukkit

View file

@ -10,7 +10,7 @@ public @interface CommandPermissions
SOURCE_TYPE_ALLOWED source();
boolean block_web_console() default false;
boolean block_host_console() default false;
boolean ignore_permissions() default true;
}

View file

@ -7,7 +7,7 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = ADMIN_LEVEL.SUPER, source = SOURCE_TYPE_ALLOWED.ONLY_CONSOLE, block_web_console = true, ignore_permissions = false)
@CommandPermissions(level = ADMIN_LEVEL.SUPER, source = SOURCE_TYPE_ALLOWED.ONLY_CONSOLE, block_host_console = true, ignore_permissions = false)
public class Command_adminmode extends TFM_Command
{
@Override

View file

@ -6,7 +6,7 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = ADMIN_LEVEL.SENIOR, source = SOURCE_TYPE_ALLOWED.BOTH, block_web_console = true, ignore_permissions = false)
@CommandPermissions(level = ADMIN_LEVEL.SENIOR, source = SOURCE_TYPE_ALLOWED.BOTH, block_host_console = true, ignore_permissions = false)
public class Command_kicknoob extends TFM_Command
{
@Override

View file

@ -16,7 +16,7 @@ public class Command_list extends TFM_Command
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (TFM_Util.isFromClanforge(sender.getName()))
if (TFM_Util.isFromHostConsole(sender.getName()))
{
List<String> player_names = new ArrayList<String>();
for (Player p : server.getOnlinePlayers())

View file

@ -0,0 +1,43 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import java.io.File;
import me.StevenLawson.TotalFreedomMod.TFM_Log;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = ADMIN_LEVEL.SENIOR, source = SOURCE_TYPE_ALLOWED.ONLY_CONSOLE, block_host_console = true, ignore_permissions = false)
public class Command_listsync extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
TFM_Util.adminAction(sender.getName(), "Downloading superadmin and permban lists from primary TotalFreedom server.", false);
try
{
TFM_Util.downloadFile("http://madgeekonline.com/apps/get_superadmins_raw.php", new File(TotalFreedomMod.plugin.getDataFolder(), TotalFreedomMod.SUPERADMIN_FILE));
TotalFreedomMod.loadSuperadminConfig();
TFM_Util.adminAction(sender.getName(), TotalFreedomMod.SUPERADMIN_FILE + " downloaded.", false);
}
catch (Exception ex)
{
TFM_Log.severe(ex);
}
try
{
TFM_Util.downloadFile("http://madgeekonline.com/apps/get_permbans_raw.php", new File(TotalFreedomMod.plugin.getDataFolder(), TotalFreedomMod.PERMBAN_FILE));
TotalFreedomMod.loadPermbanConfig();
TFM_Util.adminAction(sender.getName(), TotalFreedomMod.PERMBAN_FILE + " downloaded.", false);
}
catch (Exception ex)
{
TFM_Log.severe(ex);
}
return true;
}
}

View file

@ -9,7 +9,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitScheduler;
@CommandPermissions(level = ADMIN_LEVEL.SENIOR, source = SOURCE_TYPE_ALLOWED.ONLY_CONSOLE, block_web_console = true, ignore_permissions = false)
@CommandPermissions(level = ADMIN_LEVEL.SENIOR, source = SOURCE_TYPE_ALLOWED.ONLY_CONSOLE, block_host_console = true, ignore_permissions = false)
public class Command_lockup extends TFM_Command
{
@Override

View file

@ -6,7 +6,7 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = ADMIN_LEVEL.SENIOR, source = SOURCE_TYPE_ALLOWED.ONLY_CONSOLE, block_web_console = true, ignore_permissions = false)
@CommandPermissions(level = ADMIN_LEVEL.SENIOR, source = SOURCE_TYPE_ALLOWED.ONLY_CONSOLE, block_host_console = true, ignore_permissions = false)
public class Command_nonuke extends TFM_Command
{
@Override

View file

@ -8,7 +8,7 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = ADMIN_LEVEL.SENIOR, source = SOURCE_TYPE_ALLOWED.ONLY_CONSOLE, block_web_console = true, ignore_permissions = false)
@CommandPermissions(level = ADMIN_LEVEL.SENIOR, source = SOURCE_TYPE_ALLOWED.ONLY_CONSOLE, block_host_console = true, ignore_permissions = false)
public class Command_onlinemode extends TFM_Command
{
@Override

View file

@ -8,7 +8,7 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = ADMIN_LEVEL.SENIOR, source = SOURCE_TYPE_ALLOWED.ONLY_CONSOLE, block_web_console = true, ignore_permissions = false)
@CommandPermissions(level = ADMIN_LEVEL.SENIOR, source = SOURCE_TYPE_ALLOWED.ONLY_CONSOLE, block_host_console = true, ignore_permissions = false)
public class Command_permban extends TFM_Command
{
@Override

View file

@ -5,7 +5,7 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = ADMIN_LEVEL.SENIOR, source = SOURCE_TYPE_ALLOWED.ONLY_CONSOLE, block_web_console = true, ignore_permissions = false)
@CommandPermissions(level = ADMIN_LEVEL.SENIOR, source = SOURCE_TYPE_ALLOWED.ONLY_CONSOLE, block_host_console = true, ignore_permissions = false)
public class Command_prelog extends TFM_Command
{
@Override

View file

@ -6,7 +6,7 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = ADMIN_LEVEL.SENIOR, source = SOURCE_TYPE_ALLOWED.ONLY_CONSOLE, block_web_console = true, ignore_permissions = false)
@CommandPermissions(level = ADMIN_LEVEL.SENIOR, source = SOURCE_TYPE_ALLOWED.ONLY_CONSOLE, block_host_console = true, ignore_permissions = false)
public class Command_rawsay extends TFM_Command
{
@Override

View file

@ -7,7 +7,7 @@ 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, block_web_console = false, ignore_permissions = false)
@CommandPermissions(level = ADMIN_LEVEL.SUPER, source = SOURCE_TYPE_ALLOWED.BOTH, block_host_console = false, ignore_permissions = false)
public class Command_ro extends TFM_Command
{
@Override

View file

@ -20,7 +20,7 @@ public class Command_say extends TFM_Command
String message = StringUtils.join(args, " ");
if (senderIsConsole && TFM_Util.isFromClanforge(sender.getName()))
if (senderIsConsole && TFM_Util.isFromHostConsole(sender.getName()))
{
if (message.equalsIgnoreCase("WARNING: Server is restarting, you will be kicked"))
{

View file

@ -6,7 +6,7 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = ADMIN_LEVEL.SENIOR, source = SOURCE_TYPE_ALLOWED.ONLY_CONSOLE, block_web_console = true, ignore_permissions = false)
@CommandPermissions(level = ADMIN_LEVEL.SENIOR, source = SOURCE_TYPE_ALLOWED.ONLY_CONSOLE, block_host_console = true, ignore_permissions = false)
public class Command_terminal extends TFM_Command
{
@Override

View file

@ -6,7 +6,7 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = ADMIN_LEVEL.SENIOR, source = SOURCE_TYPE_ALLOWED.ONLY_CONSOLE, block_web_console = true, ignore_permissions = false)
@CommandPermissions(level = ADMIN_LEVEL.SENIOR, source = SOURCE_TYPE_ALLOWED.ONLY_CONSOLE, block_host_console = true, ignore_permissions = false)
public class Command_wipeflatlands extends TFM_Command
{
@Override

View file

@ -8,7 +8,7 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = ADMIN_LEVEL.SENIOR, source = SOURCE_TYPE_ALLOWED.ONLY_CONSOLE, block_web_console = true, ignore_permissions = false)
@CommandPermissions(level = ADMIN_LEVEL.SENIOR, source = SOURCE_TYPE_ALLOWED.ONLY_CONSOLE, block_host_console = true, ignore_permissions = false)
public class Command_ziptool extends TFM_Command
{
@Override

View file

@ -53,9 +53,9 @@ public class TFM_Command
ADMIN_LEVEL level = permissions.level();
SOURCE_TYPE_ALLOWED source = permissions.source();
boolean block_web_console = permissions.block_web_console();
boolean block_web_console = permissions.block_host_console();
//TFM_Log.info("Level: " + level + ", Source: " + source + ", BWC: " + block_web_console);
//TFM_Log.info("Level: " + level + ", Source: " + source + ", BWC: " + block_host_console);
Player sender_p = null;
if (sender instanceof Player)
@ -73,7 +73,7 @@ public class TFM_Command
{
return false;
}
else if (block_web_console && TFM_Util.isFromClanforge(sender.getName()))
else if (block_web_console && TFM_Util.isFromHostConsole(sender.getName()))
{
return false;
}

View file

@ -2,6 +2,9 @@ package me.StevenLawson.TotalFreedomMod;
import java.io.*;
import java.net.URI;
import java.net.URL;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
@ -26,7 +29,6 @@ public class TFM_Util
private static final Map<String, Integer> eject_tracker = new HashMap<String, Integer>();
public static final Map<String, EntityType> mobtypes = new HashMap<String, EntityType>();
public static final List<String> stop_commands = Arrays.asList("stop", "off", "end", "halt", "die");
public static final List<String> restricted_senders = Arrays.asList("rcon", "remotebukkit");
static
{
@ -904,9 +906,9 @@ public class TFM_Util
}
}
public static boolean isFromClanforge(String sender_name)
public static boolean isFromHostConsole(String sender_name)
{
return restricted_senders.contains(sender_name.toLowerCase());
return TotalFreedomMod.host_sender_names.contains(sender_name.toLowerCase());
}
public static List<String> removeDuplicates(List<String> old_list)
@ -987,27 +989,13 @@ public class TFM_Util
return affected;
}
// I wrote all this before i discovered getTargetBlock >.> - might come in handy some day...
// public static final double LOOKAT_VIEW_HEIGHT = 1.65;
// public static final double LOOKAT_STEP_DISTANCE = 0.2;
//
// public static Location getLookatLocation(Player player)
// {
// Location player_loc = player.getLocation();
//
// Vector player_pos = player_loc.toVector().add(new Vector(0.0, LOOKAT_VIEW_HEIGHT, 0.0));
// Vector player_dir = player_loc.getDirection().normalize();
//
// for (double offset = 0.0; offset <= 300.0; offset += LOOKAT_STEP_DISTANCE)
// {
// Location check_loc = player_pos.clone().add(player_dir.clone().multiply(offset)).toLocation(player.getWorld());
//
// if (!check_loc.getBlock().isEmpty())
// {
// return check_loc;
// }
// }
//
// return null;
// }
public static void downloadFile(String url, File output_file) throws Exception
{
URL website = new URL(url);
ReadableByteChannel rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(output_file);
fos.getChannel().transferFrom(rbc, 0, 1 << 24);
fos.close();
}
}

View file

@ -24,7 +24,7 @@ import org.bukkit.plugin.java.JavaPlugin;
public class TotalFreedomMod extends JavaPlugin
{
private final Server server = Bukkit.getServer();
public static final Server server = Bukkit.getServer();
public static final long HEARTBEAT_RATE = 5L; //Seconds
@ -72,12 +72,6 @@ public class TotalFreedomMod extends JavaPlugin
registerEventHandlers();
server.getScheduler().scheduleAsyncRepeatingTask(this, new TFM_Heartbeat(this), HEARTBEAT_RATE * 20L, HEARTBEAT_RATE * 20L);
TFM_Log.info("Plugin Enabled - Version: " + TotalFreedomMod.pluginVersion + "." + TotalFreedomMod.buildNumber + " by Madgeek1450 and DarthSalamon");
TFM_Util.deleteFolder(new File("./_deleteme"));
if (generateFlatlands)
{
TFM_Util.wipeFlatlandsIfFlagged();
@ -100,6 +94,12 @@ public class TotalFreedomMod extends JavaPlugin
TFM_ProtectedArea.loadProtectedAreas();
TFM_ProtectedArea.autoAddSpawnpoints();
}
TFM_Util.deleteFolder(new File("./_deleteme"));
server.getScheduler().scheduleAsyncRepeatingTask(this, new TFM_Heartbeat(this), HEARTBEAT_RATE * 20L, HEARTBEAT_RATE * 20L);
TFM_Log.info("Plugin Enabled - Version: " + TotalFreedomMod.pluginVersion + "." + TotalFreedomMod.buildNumber + " by Madgeek1450 and DarthSalamon");
}
@Override
@ -207,13 +207,14 @@ public class TotalFreedomMod extends JavaPlugin
public static boolean protectedAreasEnabled = true;
public static boolean autoProtectSpawnpoints = true;
public static double autoProtectRadius = 25.0D;
public static List<String> host_sender_names = Arrays.asList("rcon", "remotebukkit");
public void loadMainConfig()
public static void loadMainConfig()
{
try
{
TFM_Util.createDefaultConfiguration(CONFIG_FILE, getFile());
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(getDataFolder(), CONFIG_FILE));
TFM_Util.createDefaultConfiguration(CONFIG_FILE, plugin_file);
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder(), CONFIG_FILE));
allowFirePlace = config.getBoolean("allow_fire_place", allowFirePlace);
allowFireSpread = config.getBoolean("allow_fire_spread", allowFireSpread);
@ -247,6 +248,7 @@ public class TotalFreedomMod extends JavaPlugin
protectedAreasEnabled = config.getBoolean("protected_areas_enabled", protectedAreasEnabled);
autoProtectSpawnpoints = config.getBoolean("auto_protect_spawnpoints", autoProtectSpawnpoints);
autoProtectRadius = config.getDouble("auto_protect_radius", autoProtectRadius);
host_sender_names = config.getStringList("host_sender_names");
}
catch (Exception ex)
{
@ -259,7 +261,7 @@ public class TotalFreedomMod extends JavaPlugin
@Deprecated
public static List<String> superadmin_ips = new ArrayList<String>();
public void loadSuperadminConfig()
public static void loadSuperadminConfig()
{
try
{
@ -278,12 +280,12 @@ public class TotalFreedomMod extends JavaPlugin
public static List<String> permbanned_players = new ArrayList<String>();
public static List<String> permbanned_ips = new ArrayList<String>();
public void loadPermbanConfig()
public static void loadPermbanConfig()
{
try
{
TFM_Util.createDefaultConfiguration(PERMBAN_FILE, getFile());
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(getDataFolder(), PERMBAN_FILE));
TFM_Util.createDefaultConfiguration(PERMBAN_FILE, plugin_file);
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder(), PERMBAN_FILE));
permbanned_players = new ArrayList<String>();
permbanned_ips = new ArrayList<String>();
@ -292,7 +294,7 @@ public class TotalFreedomMod extends JavaPlugin
{
permbanned_players.add(user.toLowerCase().trim());
List<String> user_ips = (List<String>) config.getStringList(user);
List<String> user_ips = config.getStringList(user);
for (String ip : user_ips)
{
ip = ip.toLowerCase().trim();
@ -309,7 +311,7 @@ public class TotalFreedomMod extends JavaPlugin
}
}
private void registerEventHandlers()
private static void registerEventHandlers()
{
PluginManager pm = server.getPluginManager();
@ -319,14 +321,14 @@ public class TotalFreedomMod extends JavaPlugin
pm.registerEvents(new TFM_WeatherListener(), plugin);
}
private void setAppProperties()
private static void setAppProperties()
{
try
{
InputStream in;
Properties props = new Properties();
in = getClass().getResourceAsStream("/appinfo.properties");
in = plugin.getClass().getResourceAsStream("/appinfo.properties");
props.load(in);
in.close();

View file

@ -38,7 +38,7 @@ commands:
description: Fill nearby dispensers with a set of items of your choice.
usage: /<command> <radius> <comma,separated,items>
doom:
description: Owner command - For the bad Superadmins.
description: Senior Command - For the bad Superadmins.
usage: /<command> <playername>
enchant:
description: Enchant items.
@ -98,11 +98,14 @@ commands:
description: Lists the real names of all online players.
usage: /<command>
aliases: [who]
listsync:
description: Senior Command - Download the superadmin and permban lists from the main TotalFreedom server.
usave: /<command>
lockup:
description: Console command - Block target's minecraft input. This is evil, and I never should have wrote it.
usage: /<command> <all | purge | <<partialname> on | off>>
moblimiter:
description: Owner command - Controll mob rezzing parameters.
description: Senior Command - Control mob rezzing parameters.
usage: /<command> <on|off|setmax <count>|dragon|giant|ghast|slime>
mp:
description: Purge all mobs in all worlds.
@ -159,7 +162,7 @@ commands:
description: Shows your rank.
usage: /<command>
rawsay:
description: Owner Command - Broadcasts the given message with no extra formatting.
description: Senior Command - Broadcasts the given message with no extra formatting.
usage: /<command> <message>
rd:
description: Superadmin command - Remove various server entities that may cause lag, such as dropped items, minecarts, and boats.
@ -168,7 +171,7 @@ commands:
description: Superadmin Command - Remove all blocks of a certain type in the radius of certain players.
usage: /<command> <block> [radius (default=50)] [player]
saconfig:
description: Owner command - Manage superadmins.
description: Senior Command - Manage superadmins.
usage: /<command> <list | clean | <add|delete> <username>>
say:
description: Broadcasts the given message as the console, includes sender name.
@ -226,8 +229,8 @@ commands:
description: Superadmin command - Run any command on all users, username placeholder = ?.
usage: /<command> [fluff] ? [fluff] ?
wipeflatlands:
description: Owner command - Wipe the flatlands map. Requires manual restart after command is used.
description: Senior Command - Wipe the flatlands map. Requires manual restart after command is used.
usage: /<command>
# ziptool:
# description: Owner command - Zip and unzip files.
# description: Senior Command - Zip and unzip files.
# usage: /<command> <zip <directory>> | <unzip <file>>