made debug option configurable as well, changed text colors for optional/required command values, updated README.md

This commit is contained in:
Brettflan 2011-04-03 23:51:57 -05:00
parent 7378d58405
commit 2e7978f890
5 changed files with 55 additions and 14 deletions

View File

@ -1,4 +1,14 @@
WorldBorder
===========
A Bukkit plugin to provide borders for your worlds, to limit their sizes.
A Bukkit plugin to provide borders for your worlds, to limit their sizes.
Description
===========
This plugin is intended to be able to supersede BorderGuard Lite and rBorder in functionality, and to impact server performance as little as possible, hopefully very close to being on par with rBorder. And, like rBorder, the source is available. Configuration and border setup is done using commands in-game or through the server console. All commands support GroupManager and Permissions plugin, so you can use either to set up command permissions.
More Info
=========
Bukkit Forum discussion: <link forthcoming>

View File

@ -30,12 +30,12 @@ public class Config
private static GroupManager GroupPlugin = null;
private static final Logger mcLog = Logger.getLogger("Minecraft");
public static DecimalFormat coord = new DecimalFormat("0.0");
public static final boolean DEBUG = false;
// actual configuration values which can be changed
private static boolean shapeRound = false;
private static Map<String, BorderData> borders = Collections.synchronizedMap(new HashMap<String, BorderData>());
private static String message;
private static boolean DEBUG = false;
public static void setBorder(String world, BorderData border)
{
@ -113,6 +113,18 @@ public class Config
return shapeRound;
}
public static void setDebug(boolean debugMode)
{
DEBUG = debugMode;
Log("Debug mode " + (DEBUG ? "enabled" : "disabled") + ".");
save(true);
}
public static boolean Debug()
{
return DEBUG;
}
public static void loadPermissions(WorldBorder plugin)
{
if (GroupPlugin != null || Permissions != null || plugin == null)
@ -193,6 +205,7 @@ public class Config
message = cfg.getString("message");
shapeRound = cfg.getBoolean("round-border", false);
LogConfig("Using " + (shapeRound ? "round" : "square") + " border shape.");
DEBUG = cfg.getBoolean("debug-mode", false);
borders.clear();
@ -228,6 +241,7 @@ public class Config
cfg.setProperty("message", message);
cfg.setProperty("round-border", shapeRound);
cfg.setProperty("debug-mode", DEBUG);
cfg.removeProperty("worlds");
Iterator world = borders.entrySet().iterator();

View File

@ -23,8 +23,8 @@ public class WBCommand implements CommandExecutor
{
Player player = (sender instanceof Player) ? (Player)sender : null;
String cmd = ChatColor.AQUA + ((player == null) ? "wborder" : "/wborder");
String cmdW = ChatColor.AQUA + ((player == null) ? "wborder " + ChatColor.DARK_GREEN + "<world>" : "/wborder " + ChatColor.GREEN + "[world]") + ChatColor.AQUA;
String cmd = ChatColor.AQUA + ((player == null) ? "wb" : "/wb");
String cmdW = ChatColor.AQUA + ((player == null) ? "wb " + ChatColor.GREEN + "<world>" : "/wb " + ChatColor.DARK_GREEN + "[world]") + ChatColor.AQUA;
// "set" command from player or console, world specified
if (split.length == 5 && split[1].equalsIgnoreCase("set"))
@ -271,24 +271,41 @@ public class WBCommand implements CommandExecutor
sender.sendMessage("WorldBorder configuration reloaded.");
}
// "debug" command from player or console
else if (split.length == 2 && split[0].equalsIgnoreCase("debug"))
{
if (!Config.HasPermission(player, "debug")) return true;
Config.setDebug(split[1].equalsIgnoreCase("on"));
if (player != null)
Config.Log((Config.Debug() ? "Enabling" : "Disabling") + " debug output at the command of player \"" + player.getName() + "\".");
if (player != null)
sender.sendMessage("Debug mode " + (Config.Debug() ? "enabled" : "disabled") + ".");
}
// we couldn't decipher any known commands, so show help
else
{
if (!Config.HasPermission(player, "help")) return true;
sender.sendMessage(ChatColor.WHITE + plugin.getDescription().getFullName() + " - commands (" + (player != null ? ChatColor.GREEN + "[optional] " : "") + ChatColor.DARK_GREEN + "<required>" + ChatColor.WHITE + "):");
sender.sendMessage(ChatColor.WHITE + plugin.getDescription().getFullName() + " - commands (" + (player != null ? ChatColor.DARK_GREEN + "[optional] " : "") + ChatColor.GREEN + "<required>" + ChatColor.WHITE + "):");
if (player != null)
sender.sendMessage(cmd+" set " + ChatColor.DARK_GREEN + "<radius>" + ChatColor.WHITE + " - set world border, centered on you.");
sender.sendMessage(cmdW+" set " + ChatColor.DARK_GREEN + "<radius> <x> <z>" + ChatColor.WHITE + " - set world border.");
sender.sendMessage(cmdW+" radius " + ChatColor.DARK_GREEN + "<radius>" + ChatColor.WHITE + " - change a border radius.");
sender.sendMessage(cmd+" set " + ChatColor.GREEN + "<radius>" + ChatColor.WHITE + " - set world border, centered on you.");
sender.sendMessage(cmdW+" set " + ChatColor.GREEN + "<radius> <x> <z>" + ChatColor.WHITE + " - set world border.");
sender.sendMessage(cmdW+" radius " + ChatColor.GREEN + "<radius>" + ChatColor.WHITE + " - change a border radius.");
sender.sendMessage(cmdW+" clear" + ChatColor.WHITE + " - remove border for this world.");
sender.sendMessage(cmd+" clear all" + ChatColor.WHITE + " - remove border for all worlds.");
sender.sendMessage(cmd+" list" + ChatColor.WHITE + " - show border information for all worlds.");
sender.sendMessage(cmd+" shape " + ChatColor.DARK_GREEN + "<round|square>" + ChatColor.WHITE + " - set the border shape.");
sender.sendMessage(cmd+" shape " + ChatColor.GREEN + "<round|square>" + ChatColor.WHITE + " - set the border shape.");
sender.sendMessage(cmd+" getmsg" + ChatColor.WHITE + " - display border message.");
sender.sendMessage(cmd+" setmsg " + ChatColor.DARK_GREEN + "<text>" + ChatColor.WHITE + " - set border message.");
sender.sendMessage(cmd+" setmsg " + ChatColor.GREEN + "<text>" + ChatColor.WHITE + " - set border message.");
if (player == null)
{
sender.sendMessage(cmd+" reload" + ChatColor.WHITE + " - re-load data from config.yml.");
sender.sendMessage(cmd+" debug " + ChatColor.GREEN + "<on|off>" + ChatColor.WHITE + " - turn console debug output on or off.");
}
}
return true;

View File

@ -95,7 +95,7 @@ public class WBPlayerListener extends PlayerListener
private static Location newLocation(Player player, Location loc, BorderData border)
{
if (Config.DEBUG)
if (Config.Debug())
{
Config.LogWarn("Border crossing. Border " + border.toString());
Config.LogWarn("Player position X: " + Config.coord.format(loc.getX()) + " Y: " + Config.coord.format(loc.getY()) + " Z: " + Config.coord.format(loc.getZ()));
@ -106,12 +106,12 @@ public class WBPlayerListener extends PlayerListener
// it's remotely possible (such as in the Nether) a suitable location isn't available, in which case...
if (newLoc == null)
{
if (Config.DEBUG)
if (Config.Debug())
Config.LogWarn("Target new location unviable, using spawn.");
newLoc = player.getServer().getWorlds().get(0).getSpawnLocation();
}
if (Config.DEBUG)
if (Config.Debug())
Config.LogWarn("New position X: " + Config.coord.format(newLoc.getX()) + " Y: " + Config.coord.format(newLoc.getY()) + " Z: " + Config.coord.format(newLoc.getZ()));
player.sendMessage(ChatColor.RED + Config.Message());

View File

@ -1,7 +1,7 @@
name: WorldBorder
author: Brettflan
description: Limit the size of your worlds with a border, round or square.
version: 0.9 PRE-RELEASE
version: 0.9 DEV
main: com.wimbli.WorldBorder.WorldBorder
commands:
wborder: