JavaDoc for commands and War

This commit is contained in:
Tim Düsterhus 2011-08-14 12:57:16 +02:00
parent 7fef7c9649
commit 0019e7e107
25 changed files with 238 additions and 50 deletions

View File

@ -180,7 +180,7 @@ public class War extends JavaPlugin {
} }
/** /**
* Handles war commands * @see JavaPlugin.onCommand()
*/ */
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) { public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
return this.commandHandler.handle(sender, cmd, args); return this.commandHandler.handle(sender, cmd, args);
@ -514,9 +514,9 @@ public class War extends JavaPlugin {
/** /**
* Colors the teams and examples in messages * Colors the teams and examples in messages
* *
* @param String str message-string * @param str message-string
* @param String msgColor current message-color * @param msgColor current message-color
* @return String Message with colored teams * @return Message with colored teams
*/ */
private String colorKnownTokens(String str, ChatColor msgColor) { private String colorKnownTokens(String str, ChatColor msgColor) {
for (TeamKind kind : TeamKinds.getTeamkinds()) { for (TeamKind kind : TeamKinds.getTeamkinds()) {
@ -529,8 +529,8 @@ public class War extends JavaPlugin {
/** /**
* Logs a specified message with a specified level * Logs a specified message with a specified level
* *
* @param String str message to log * @param str message to log
* @param Level lvl level to use * @param lvl level to use
*/ */
public void log(String str, Level lvl) { public void log(String str, Level lvl) {
this.getLogger().log(lvl, "War> " + str); this.getLogger().log(lvl, "War> " + str);
@ -551,6 +551,12 @@ public class War extends JavaPlugin {
return null; return null;
} }
/**
* Checks whether the given player is allowed to play war.
*
* @param player Player to check
* @return true if the player may play war
*/
public boolean canPlayWar(Player player) { public boolean canPlayWar(Player player) {
if (War.permissionHandler != null && (War.permissionHandler.has(player, "war.player") || War.permissionHandler.has(player, "War.player"))) { if (War.permissionHandler != null && (War.permissionHandler.has(player, "war.player") || War.permissionHandler.has(player, "War.player"))) {
return true; return true;
@ -562,6 +568,12 @@ public class War extends JavaPlugin {
return false; return false;
} }
/**
* Checks whether the given player is allowed to warp.
*
* @param player Player to check
* @return true if the player may warp
*/
public boolean canWarp(Player player) { public boolean canWarp(Player player) {
if (War.permissionHandler != null && (War.permissionHandler.has(player, "war.warp") || War.permissionHandler.has(player, "War.warp"))) { if (War.permissionHandler != null && (War.permissionHandler.has(player, "war.warp") || War.permissionHandler.has(player, "War.warp"))) {
return true; return true;
@ -573,6 +585,12 @@ public class War extends JavaPlugin {
return false; return false;
} }
/**
* Checks whether the given player is allowed to build outside zones
*
* @param player Player to check
* @return true if the player may build outside zones
*/
public boolean canBuildOutsideZone(Player player) { public boolean canBuildOutsideZone(Player player) {
if (this.isBuildInZonesOnly()) { if (this.isBuildInZonesOnly()) {
if (War.permissionHandler != null && (War.permissionHandler.has(player, "war.build") || War.permissionHandler.has(player, "War.build"))) { if (War.permissionHandler != null && (War.permissionHandler.has(player, "war.build") || War.permissionHandler.has(player, "War.build"))) {
@ -585,6 +603,12 @@ public class War extends JavaPlugin {
} }
} }
/**
* Checks whether the given player is allowed to pvp outside zones
*
* @param player Player to check
* @return true if the player may pvp outside zones
*/
public boolean canPvpOutsideZones(Player player) { public boolean canPvpOutsideZones(Player player) {
if (this.isPvpInZonesOnly()) { if (this.isPvpInZonesOnly()) {
if (War.permissionHandler != null && (War.permissionHandler.has(player, "war.pvp") || War.permissionHandler.has(player, "War.pvp"))) { if (War.permissionHandler != null && (War.permissionHandler.has(player, "war.pvp") || War.permissionHandler.has(player, "War.pvp"))) {
@ -597,7 +621,14 @@ public class War extends JavaPlugin {
} }
} }
/**
* Checks whether the given player is a zone maker
*
* @param player Player to check
* @return true if the player is a zone maker
*/
public boolean isZoneMaker(Player player) { public boolean isZoneMaker(Player player) {
// sort out disguised first
for (String disguised : this.zoneMakersImpersonatingPlayers) { for (String disguised : this.zoneMakersImpersonatingPlayers) {
if (disguised.equals(player.getName())) { if (disguised.equals(player.getName())) {
return false; return false;
@ -612,6 +643,7 @@ public class War extends JavaPlugin {
if (War.permissionHandler != null && (War.permissionHandler.has(player, "war.*") || War.permissionHandler.has(player, "War.*"))) { if (War.permissionHandler != null && (War.permissionHandler.has(player, "war.*") || War.permissionHandler.has(player, "War.*"))) {
return true; return true;
} else { } else {
// default to op, if no permissions are found
return player.isOp(); return player.isOp();
} }
} }

View File

@ -21,18 +21,20 @@ public class WarCommandHandler {
* @param sender The sender of the command * @param sender The sender of the command
* @param cmd The command * @param cmd The command
* @param args The arguments * @param args The arguments
* @return Success * @see War.onCommand()
*/ */
public boolean handle(CommandSender sender, Command cmd, String[] args) { public boolean handle(CommandSender sender, Command cmd, String[] args) {
String command = cmd.getName(); String command = cmd.getName();
String[] arguments = null; String[] arguments = null;
// parse prefixed commands
if ((command.equals("war") || command.equals("War")) && args.length > 0) { if ((command.equals("war") || command.equals("War")) && args.length > 0) {
command = args[0]; command = args[0];
arguments = new String[args.length - 1]; arguments = new String[args.length - 1];
for (int i = 1; i <= arguments.length; i++) { for (int i = 1; i <= arguments.length; i++) {
arguments[i - 1] = args[i]; arguments[i - 1] = args[i];
} }
if (arguments.length == 1 && (arguments[0].equals("help") || arguments[0].equals("h"))) { if (arguments.length == 1 && (arguments[0].equals("help") || arguments[0].equals("h"))) {
// show /war help // show /war help
War.war.badMsg(sender, cmd.getUsage()); War.war.badMsg(sender, cmd.getUsage());
@ -102,9 +104,11 @@ public class WarCommandHandler {
// we are not responsible for any other command // we are not responsible for any other command
} }
catch (NotZoneMakerException e) { catch (NotZoneMakerException e) {
// user is no zonemaker -> flame him :D
War.war.badMsg(sender, "You can't do this if you are not a warzone maker."); War.war.badMsg(sender, "You can't do this if you are not a warzone maker.");
} }
catch (Exception e) { catch (Exception e) {
// generally catch exceptions and log them
War.war.log("An error occured while handling command " + cmd.getName() + ". Exception:" + e.getClass().toString() + " " + e.getMessage(), Level.WARNING); War.war.log("An error occured while handling command " + cmd.getName() + ". Exception:" + e.getClass().toString() + " " + e.getMessage(), Level.WARNING);
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -138,6 +138,7 @@ public class WarEntityListener extends EntityListener {
@Override @Override
public void onEntityExplode(EntityExplodeEvent event) { public void onEntityExplode(EntityExplodeEvent event) {
if (!War.war.isLoaded()) return; if (!War.war.isLoaded()) return;
// protect zones elements, lobbies and warhub from creepers // protect zones elements, lobbies and warhub from creepers
List<Block> explodedBlocks = event.blockList(); List<Block> explodedBlocks = event.blockList();
for (Block block : explodedBlocks) { for (Block block : explodedBlocks) {
@ -242,7 +243,10 @@ public class WarEntityListener extends EntityListener {
*/ */
@Override @Override
public void onEntityRegainHealth(EntityRegainHealthEvent event) { public void onEntityRegainHealth(EntityRegainHealthEvent event) {
if (!War.war.isLoaded() || event.getRegainReason() != RegainReason.REGEN) return; if (!War.war.isLoaded()) return;
// break if reason was not regen
if (event.getRegainReason() != RegainReason.REGEN) return;
Entity entity = event.getEntity(); Entity entity = event.getEntity();
if (!(entity instanceof Player)) return; if (!(entity instanceof Player)) return;

View File

@ -5,32 +5,80 @@ import org.bukkit.command.CommandSender;
import bukkit.tommytony.war.War; import bukkit.tommytony.war.War;
import bukkit.tommytony.war.WarCommandHandler; import bukkit.tommytony.war.WarCommandHandler;
/**
* Represents a war command
*
* @author Tim Düsterhus
*/
public abstract class AbstractWarCommand { public abstract class AbstractWarCommand {
/**
* The sender of this command
*
* @var sender
*/
private CommandSender sender; private CommandSender sender;
/**
* The arguments of this command
*
* @var args
*/
protected String[] args; protected String[] args;
/**
* Instance of WarCommandHandler
*
* @var handler
*/
protected WarCommandHandler handler; protected WarCommandHandler handler;
public AbstractWarCommand(WarCommandHandler handler, CommandSender sender, String[] args) { public AbstractWarCommand(WarCommandHandler handler, CommandSender sender, String[] args) {
this.handler = handler; this.handler = handler;
this.setSender(sender); this.setSender(sender);
this.args = args; this.args = args;
} }
/**
* Handles the command
*
* @return true if command was used the right way
*/
abstract public boolean handle(); abstract public boolean handle();
/**
* Sends a success message
*
* @param message message to send
*/
public void msg(String message) { public void msg(String message) {
War.war.msg(getSender(), message); War.war.msg(getSender(), message);
} }
/**
* Sends a failure message
*
* @param message message to send
*/
public void badMsg(String message) { public void badMsg(String message) {
War.war.badMsg(getSender(), message); War.war.badMsg(getSender(), message);
} }
/**
* Changes the command-sender
*
* @param sender new sender
*/
public void setSender(CommandSender sender) { public void setSender(CommandSender sender) {
this.sender = sender; this.sender = sender;
} }
/**
* Gets the command-sender
*
* @return Command-Sender
*/
public CommandSender getSender() { public CommandSender getSender() {
return sender; return this.sender;
} }
} }

View File

@ -7,16 +7,24 @@ import org.bukkit.entity.Player;
import bukkit.tommytony.war.War; import bukkit.tommytony.war.War;
import bukkit.tommytony.war.WarCommandHandler; import bukkit.tommytony.war.WarCommandHandler;
/**
* Represents a command that may only be used by zone makers
*
* @author Tim Düsterhus
*/
public abstract class AbstractZoneMakerCommand extends AbstractWarCommand { public abstract class AbstractZoneMakerCommand extends AbstractWarCommand {
public AbstractZoneMakerCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NotZoneMakerException { public AbstractZoneMakerCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NotZoneMakerException {
super(handler, sender, args); super(handler, sender, args);
if (sender instanceof Player) { if (sender instanceof Player) {
// for players check War.isZoneMaker()
if (!War.war.isZoneMaker((Player) sender)) { if (!War.war.isZoneMaker((Player) sender)) {
throw new NotZoneMakerException(); throw new NotZoneMakerException();
} }
} }
else if (!(sender instanceof ConsoleCommandSender)) { else if (!(sender instanceof ConsoleCommandSender)) {
// otherwise only the console is a legimate sender
throw new NotZoneMakerException(); throw new NotZoneMakerException();
} }
} }

View File

@ -10,6 +10,11 @@ import com.tommytony.war.mappers.WarzoneMapper;
import bukkit.tommytony.war.WarCommandHandler; import bukkit.tommytony.war.WarCommandHandler;
/**
* Deletes a monument.
*
* @author Tim Düsterhus
*/
public class DeleteMonumentCommand extends AbstractZoneMakerCommand { public class DeleteMonumentCommand extends AbstractZoneMakerCommand {
public DeleteMonumentCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NotZoneMakerException { public DeleteMonumentCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NotZoneMakerException {
super(handler, sender, args); super(handler, sender, args);
@ -18,6 +23,7 @@ public class DeleteMonumentCommand extends AbstractZoneMakerCommand {
@Override @Override
public boolean handle() { public boolean handle() {
Warzone zone; Warzone zone;
if (this.args.length == 0) { if (this.args.length == 0) {
return false; return false;
} else if (this.args.length == 2) { } else if (this.args.length == 2) {
@ -38,6 +44,7 @@ public class DeleteMonumentCommand extends AbstractZoneMakerCommand {
} else { } else {
return false; return false;
} }
if (zone == null) { if (zone == null) {
return true; return true;
} }

View File

@ -11,6 +11,11 @@ import com.tommytony.war.mappers.WarzoneMapper;
import bukkit.tommytony.war.WarCommandHandler; import bukkit.tommytony.war.WarCommandHandler;
/**
* Deletes a team.
*
* @author Tim Düsterhus
*/
public class DeleteTeamCommand extends AbstractZoneMakerCommand { public class DeleteTeamCommand extends AbstractZoneMakerCommand {
public DeleteTeamCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NotZoneMakerException { public DeleteTeamCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NotZoneMakerException {
super(handler, sender, args); super(handler, sender, args);
@ -19,6 +24,7 @@ public class DeleteTeamCommand extends AbstractZoneMakerCommand {
@Override @Override
public boolean handle() { public boolean handle() {
Warzone zone; Warzone zone;
if (this.args.length == 0) { if (this.args.length == 0) {
return false; return false;
} else if (this.args.length == 2) { } else if (this.args.length == 2) {
@ -39,6 +45,7 @@ public class DeleteTeamCommand extends AbstractZoneMakerCommand {
} else { } else {
return false; return false;
} }
if (zone == null) { if (zone == null) {
return false; return false;
} }

View File

@ -11,6 +11,11 @@ import com.tommytony.war.mappers.WarMapper;
import bukkit.tommytony.war.War; import bukkit.tommytony.war.War;
import bukkit.tommytony.war.WarCommandHandler; import bukkit.tommytony.war.WarCommandHandler;
/**
* Deletes the warhub.
*
* @author Tim Düsterhus
*/
public class DeleteWarhubCommand extends AbstractZoneMakerCommand { public class DeleteWarhubCommand extends AbstractZoneMakerCommand {
public DeleteWarhubCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NotZoneMakerException { public DeleteWarhubCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NotZoneMakerException {
super(handler, sender, args); super(handler, sender, args);
@ -21,6 +26,7 @@ public class DeleteWarhubCommand extends AbstractZoneMakerCommand {
if (this.args.length != 0) { if (this.args.length != 0) {
return false; return false;
} }
if (War.war.getWarHub() != null) { if (War.war.getWarHub() != null) {
// reset existing hub // reset existing hub
War.war.getWarHub().getVolume().resetBlocks(); War.war.getWarHub().getVolume().resetBlocks();

View File

@ -13,6 +13,11 @@ import com.tommytony.war.mappers.WarzoneMapper;
import bukkit.tommytony.war.War; import bukkit.tommytony.war.War;
import bukkit.tommytony.war.WarCommandHandler; import bukkit.tommytony.war.WarCommandHandler;
/**
* Deletes a warzone.
*
* @author Tim Düsterhus
*/
public class DeleteZoneCommand extends AbstractZoneMakerCommand { public class DeleteZoneCommand extends AbstractZoneMakerCommand {
public DeleteZoneCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NotZoneMakerException { public DeleteZoneCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NotZoneMakerException {
super(handler, sender, args); super(handler, sender, args);
@ -39,6 +44,7 @@ public class DeleteZoneCommand extends AbstractZoneMakerCommand {
} else { } else {
return false; return false;
} }
if (zone == null) { if (zone == null) {
return false; return false;
} }

View File

@ -14,6 +14,11 @@ import com.tommytony.war.TeamKinds;
import com.tommytony.war.Warzone; import com.tommytony.war.Warzone;
import com.tommytony.war.ZoneLobby; import com.tommytony.war.ZoneLobby;
/**
* Joins a team.
*
* @author Tim Düsterhus
*/
public class JoinCommand extends AbstractWarCommand { public class JoinCommand extends AbstractWarCommand {
public JoinCommand(WarCommandHandler handler, CommandSender sender, String[] args) { public JoinCommand(WarCommandHandler handler, CommandSender sender, String[] args) {
super(handler, sender, args); super(handler, sender, args);

View File

@ -7,6 +7,11 @@ import bukkit.tommytony.war.WarCommandHandler;
import com.tommytony.war.Warzone; import com.tommytony.war.Warzone;
/**
* Leaves a game.
*
* @author Tim Düsterhus
*/
public class LeaveCommand extends AbstractWarCommand { public class LeaveCommand extends AbstractWarCommand {
public LeaveCommand(WarCommandHandler handler, CommandSender sender, String[] args) { public LeaveCommand(WarCommandHandler handler, CommandSender sender, String[] args) {
super(handler, sender, args); super(handler, sender, args);

View File

@ -5,6 +5,11 @@ import org.bukkit.command.CommandSender;
import bukkit.tommytony.war.War; import bukkit.tommytony.war.War;
import bukkit.tommytony.war.WarCommandHandler; import bukkit.tommytony.war.WarCommandHandler;
/**
* Loads war.
*
* @author Tim Düsterhus
*/
public class LoadWarCommand extends AbstractZoneMakerCommand { public class LoadWarCommand extends AbstractZoneMakerCommand {
public LoadWarCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NotZoneMakerException { public LoadWarCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NotZoneMakerException {
super(handler, sender, args); super(handler, sender, args);

View File

@ -1,10 +1,10 @@
package bukkit.tommytony.war.command; package bukkit.tommytony.war.command;
/**
* NotZoneMakerException is thrown when a player is no zonemaker.
*
* @author Tim Düsterhus
*/
public class NotZoneMakerException extends Exception { public class NotZoneMakerException extends Exception {
/**
*
*/
private static final long serialVersionUID = -5412011034665080340L; private static final long serialVersionUID = -5412011034665080340L;
} }

View File

@ -9,6 +9,11 @@ import com.tommytony.war.mappers.WarzoneMapper;
import bukkit.tommytony.war.WarCommandHandler; import bukkit.tommytony.war.WarCommandHandler;
/**
* Places a monument
*
* @author Tim Düsterhus
*/
public class SetMonumentCommand extends AbstractZoneMakerCommand { public class SetMonumentCommand extends AbstractZoneMakerCommand {
public SetMonumentCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NotZoneMakerException { public SetMonumentCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NotZoneMakerException {
super(handler, sender, args); super(handler, sender, args);

View File

@ -11,6 +11,11 @@ import com.tommytony.war.mappers.WarzoneMapper;
import bukkit.tommytony.war.WarCommandHandler; import bukkit.tommytony.war.WarCommandHandler;
/**
* Places a soawn
*
* @author Tim Düsterhus
*/
public class SetTeamCommand extends AbstractZoneMakerCommand { public class SetTeamCommand extends AbstractZoneMakerCommand {
public SetTeamCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NotZoneMakerException { public SetTeamCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NotZoneMakerException {
super(handler, sender, args); super(handler, sender, args);

View File

@ -12,6 +12,11 @@ import com.tommytony.war.mappers.WarzoneMapper;
import bukkit.tommytony.war.WarCommandHandler; import bukkit.tommytony.war.WarCommandHandler;
/**
* Places a teamflag
*
* @author Tim Düsterhus
*/
public class SetTeamFlagCommand extends AbstractZoneMakerCommand { public class SetTeamFlagCommand extends AbstractZoneMakerCommand {
public SetTeamFlagCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NotZoneMakerException { public SetTeamFlagCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NotZoneMakerException {
super(handler, sender, args); super(handler, sender, args);

View File

@ -10,6 +10,11 @@ import com.tommytony.war.mappers.WarMapper;
import bukkit.tommytony.war.War; import bukkit.tommytony.war.War;
import bukkit.tommytony.war.WarCommandHandler; import bukkit.tommytony.war.WarCommandHandler;
/**
* Places the warhub
*
* @author Tim Düsterhus
*/
public class SetWarHubCommand extends AbstractZoneMakerCommand { public class SetWarHubCommand extends AbstractZoneMakerCommand {
public SetWarHubCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NotZoneMakerException { public SetWarHubCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NotZoneMakerException {
super(handler, sender, args); super(handler, sender, args);

View File

@ -11,6 +11,11 @@ import com.tommytony.war.mappers.WarzoneMapper;
import bukkit.tommytony.war.War; import bukkit.tommytony.war.War;
import bukkit.tommytony.war.WarCommandHandler; import bukkit.tommytony.war.WarCommandHandler;
/**
* Places the zonelobby
*
* @author Tim Düsterhus
*/
public class SetZoneLobbyCommand extends AbstractZoneMakerCommand { public class SetZoneLobbyCommand extends AbstractZoneMakerCommand {
public SetZoneLobbyCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NotZoneMakerException { public SetZoneLobbyCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NotZoneMakerException {

View File

@ -10,8 +10,8 @@ import com.tommytony.war.Team;
/** /**
* Sends a message to all team-members * Sends a message to all team-members
* @author das-schaf
* *
* @author Tim Düsterhus
*/ */
public class TeamCommand extends AbstractWarCommand { public class TeamCommand extends AbstractWarCommand {
public TeamCommand(WarCommandHandler handler, CommandSender sender, String[] args) { public TeamCommand(WarCommandHandler handler, CommandSender sender, String[] args) {

View File

@ -8,6 +8,11 @@ import bukkit.tommytony.war.WarCommandHandler;
import com.tommytony.war.Warzone; import com.tommytony.war.Warzone;
import com.tommytony.war.ZoneLobby; import com.tommytony.war.ZoneLobby;
/**
* Shows team information
*
* @author Tim Düsterhus
*/
public class TeamsCommand extends AbstractWarCommand { public class TeamsCommand extends AbstractWarCommand {
public TeamsCommand(WarCommandHandler handler, CommandSender sender, String[] args) { public TeamsCommand(WarCommandHandler handler, CommandSender sender, String[] args) {
super(handler, sender, args); super(handler, sender, args);

View File

@ -5,6 +5,11 @@ import org.bukkit.command.CommandSender;
import bukkit.tommytony.war.War; import bukkit.tommytony.war.War;
import bukkit.tommytony.war.WarCommandHandler; import bukkit.tommytony.war.WarCommandHandler;
/**
* Unloads war.
*
* @author Tim Düsterhus
*/
public class UnloadWarCommand extends AbstractZoneMakerCommand { public class UnloadWarCommand extends AbstractZoneMakerCommand {
public UnloadWarCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NotZoneMakerException { public UnloadWarCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NotZoneMakerException {
super(handler, sender, args); super(handler, sender, args);

View File

@ -8,6 +8,11 @@ import bukkit.tommytony.war.WarCommandHandler;
import com.tommytony.war.Warzone; import com.tommytony.war.Warzone;
/**
* Warps the player to the warhub.
*
* @author Tim Düsterhus
*/
public class WarhubCommand extends AbstractWarCommand { public class WarhubCommand extends AbstractWarCommand {
public WarhubCommand(WarCommandHandler handler, CommandSender sender, String[] args) { public WarhubCommand(WarCommandHandler handler, CommandSender sender, String[] args) {
super(handler, sender, args); super(handler, sender, args);

View File

@ -8,6 +8,11 @@ import bukkit.tommytony.war.WarCommandHandler;
import com.tommytony.war.Warzone; import com.tommytony.war.Warzone;
/**
* Warps the player to the given warzone.
*
* @author Tim Düsterhus
*/
public class WarzoneCommand extends AbstractWarCommand { public class WarzoneCommand extends AbstractWarCommand {
public WarzoneCommand(WarCommandHandler handler, CommandSender sender, String[] args) { public WarzoneCommand(WarCommandHandler handler, CommandSender sender, String[] args) {
super(handler, sender, args); super(handler, sender, args);

View File

@ -8,11 +8,17 @@ import com.tommytony.war.mappers.WarMapper;
import bukkit.tommytony.war.War; import bukkit.tommytony.war.War;
import bukkit.tommytony.war.WarCommandHandler; import bukkit.tommytony.war.WarCommandHandler;
/**
* Makes a player zonemaker and other way round.
*
* @author Tim Düsterhus
*/
public class ZoneMakerCommand extends AbstractWarCommand { public class ZoneMakerCommand extends AbstractWarCommand {
public ZoneMakerCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NotZoneMakerException { public ZoneMakerCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NotZoneMakerException {
super(handler, sender, args); super(handler, sender, args);
if (sender instanceof Player) {
if (sender instanceof Player) { // i hate java for this.
if (!War.war.isZoneMaker((Player) sender)) { if (!War.war.isZoneMaker((Player) sender)) {
for (String name : War.war.getZoneMakersImpersonatingPlayers()) { for (String name : War.war.getZoneMakersImpersonatingPlayers()) {
if (((Player) sender).getName().equals(name)) { if (((Player) sender).getName().equals(name)) {