Merging /renameZone. Maybe I would've liked this better under /zonecfg to keep the command count as low as possible, but this will do. There's too many settings already anyway. I'm keeping plugin.yml in classes because it lets me build in a snap in eclipse instead of through mvn. I know: it's lame.

This commit is contained in:
taoneill 2011-09-19 22:19:38 -04:00
commit 23893c60da
6 changed files with 173 additions and 64 deletions

View File

@ -79,6 +79,8 @@ public class WarCommandHandler {
commandObj = new ResetZoneCommand(this, sender, arguments);
} else if (command.equals("nextbattle")) {
commandObj = new NextBattleCommand(this, sender, arguments);
} else if (command.equals("renamezone")) {
commandObj = new RenameZoneCommand(this, sender, arguments);
} else if (command.equals("setteam")) {
commandObj = new SetTeamCommand(this, sender, arguments);
} else if (command.equals("deleteteam")) {
@ -112,9 +114,9 @@ public class WarCommandHandler {
e.printStackTrace();
}
if (commandObj != null) {
if(commandObj != null) {
boolean handled = commandObj.handle();
if (!handled) {
if(!handled) {
War.war.badMsg(sender, cmd.getUsage());
}
}

View File

@ -0,0 +1,98 @@
package bukkit.tommytony.war.command;
import java.io.File;
import java.util.logging.Level;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.tommytony.war.Warzone;
import com.tommytony.war.ZoneLobby;
import com.tommytony.war.mappers.PropertiesFile;
import com.tommytony.war.mappers.WarMapper;
import com.tommytony.war.mappers.WarzoneMapper;
import bukkit.tommytony.war.War;
import bukkit.tommytony.war.WarCommandHandler;
public class RenameZoneCommand extends AbstractZoneMakerCommand {
public RenameZoneCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NotZoneMakerException {
super(handler, sender, args);
}
@Override
public boolean handle() {
Warzone zone;
if (this.args.length == 2) {
zone = Warzone.getZoneByName(this.args[0]);
this.args[0] = this.args[1];
} else if (this.args.length == 1) {
if (!(this.getSender() instanceof Player)) {
return false;
}
zone = Warzone.getZoneByLocation((Player) this.getSender());
if (zone == null) {
ZoneLobby lobby = ZoneLobby.getLobbyByLocation((Player) this.getSender());
if (lobby == null) {
return false;
}
zone = lobby.getZone();
}
} else {
return false;
}
if (zone == null) {
return false;
}
// kill old reference
zone.unload();
War.war.getWarzones().remove(zone);
// rename zone file
(new File(War.war.getDataFolder().getPath() + "/warzone-" + zone.getName() + ".txt")).renameTo(new File(War.war.getDataFolder().getPath() + "/warzone-" + this.args[0] + ".txt"));
// rename zone folder
(new File(War.war.getDataFolder().getPath() + "/dat/warzone-" + zone.getName())).renameTo(new File(War.war.getDataFolder().getPath() + "/dat/warzone-" + this.args[0]));
// TODO: Move renaming into ZoneVolumeMapper?
// rename volume files
String oldStart = War.war.getDataFolder().getPath() + "/dat/warzone-" + this.args[0] + "/volume-" + zone.getName() + ".";
String newStart = War.war.getDataFolder().getPath() + "/dat/warzone-" + this.args[0] + "/volume-" + this.args[0] + ".";
(new File(oldStart + "corners")).renameTo(new File(newStart + "corners"));
(new File(oldStart + "blocks")).renameTo(new File(newStart + "blocks"));
(new File(oldStart + "signs")).renameTo(new File(newStart + "signs"));
(new File(oldStart + "invs")).renameTo(new File(newStart + "invs"));
// set new name
PropertiesFile warzoneConfig = new PropertiesFile(War.war.getDataFolder().getPath() + "/warzone-" + this.args[0] + ".txt");
warzoneConfig.setString("name", this.args[0]);
warzoneConfig.save();
warzoneConfig.close();
War.war.log("Loading zone " + this.args[0] + "...", Level.INFO);
Warzone newZone = WarzoneMapper.load(this.args[0], false);
War.war.getWarzones().add(newZone);
// zone.getVolume().loadCorners();
newZone.getVolume().loadCorners();
if (newZone.getLobby() != null) {
newZone.getLobby().getVolume().resetBlocks();
}
if (newZone.isResetOnLoad()) {
newZone.getVolume().resetBlocks();
}
newZone.initializeZone();
// save war config
WarMapper.save();
if (War.war.getWarHub() != null) { // warhub has to change
War.war.getWarHub().getVolume().resetBlocks();
War.war.getWarHub().initialize();
}
this.msg("Warzone " + zone.getName() + " renamed to " + this.args[0] + ".");
return true;
}
}

View File

@ -546,5 +546,4 @@ public class WarzoneMapper {
War.war.log("Failed to delete file " + zoneFile.getName(), Level.WARNING);
}
}
}

View File

@ -501,11 +501,11 @@ public class ZoneVolumeMapper {
* war Instance of war
*/
public static void delete(Volume volume) {
ZoneVolumeMapper.deleteFile("War/dat/volume-" + volume.getName() + ".dat");
ZoneVolumeMapper.deleteFile("War/dat/volume-" + volume.getName() + ".corners");
ZoneVolumeMapper.deleteFile("War/dat/volume-" + volume.getName() + ".blocks");
ZoneVolumeMapper.deleteFile("War/dat/volume-" + volume.getName() + ".signs");
ZoneVolumeMapper.deleteFile("War/dat/volume-" + volume.getName() + ".invs");
ZoneVolumeMapper.deleteFile(War.war.getDataFolder().getPath() + "/dat/volume-" + volume.getName() + ".dat");
ZoneVolumeMapper.deleteFile(War.war.getDataFolder().getPath() + "/dat/volume-" + volume.getName() + ".corners");
ZoneVolumeMapper.deleteFile(War.war.getDataFolder().getPath() + "/dat/volume-" + volume.getName() + ".blocks");
ZoneVolumeMapper.deleteFile(War.war.getDataFolder().getPath() + "/dat/volume-" + volume.getName() + ".signs");
ZoneVolumeMapper.deleteFile(War.war.getDataFolder().getPath() + "/dat/volume-" + volume.getName() + ".invs");
}
/**

View File

@ -34,65 +34,65 @@ commands:
# Player commands
warzones:
description: War> Lists the warzones on the server. Each warzone is an independent arena.
usage: Lists the warzones on the server. Each warzone is an independent arena.
usage: Lists the warzones on the server. Each warzone is an independent arena.
Ex - /warzones
zones:
description: War> Shortcut for /warzones.
usage: Lists the warzones on the server. Each warzone is an independent arena.
usage: Lists the warzones on the server. Each warzone is an independent arena.
Ex - /zones
warzone:
description: War> Teleports you to the specified warzone's lobby.
usage: Teleports you to the specified warzone's lobby.
usage: Teleports you to the specified warzone's lobby.
Ex - /warzone <zone-name>
zone:
description: War> Shortcut for /warzone.
usage: Teleports you to the specified warzone's lobby.
usage: Teleports you to the specified warzone's lobby.
Ex - /zone <zone-name>
warhub:
description: War> Teleports you to the warhub, if it exists. The warhub offers portals to reach each warzone on the server.
usage: Teleports you to the warhub, if it exists.
usage: Teleports you to the warhub, if it exists.
Ex - /warhub
teams:
description: War> Lists the teams in the warzone.
usage: Lists the teams in the warzone. Use zone name when outside warzone.
usage: Lists the teams in the warzone. Use zone name when outside warzone.
Ex - /teams [zone-name]
join:
description: War> Use to change teams. Also used instead of walking in the team gate in the lobby.
usage: Use to change teams. Also used instead of walking in the team gate in the lobby. Must be standing in warzone or lobby.
usage: Use to change teams. Also used instead of walking in the team gate in the lobby. Must be standing in warzone or lobby.
Ex - /join <team-color>
leave:
description: War> Use to leave a warzone. Teleports you back to the lobby.
usage: Use to leave a warzone. Teleports you back to the lobby. Must be in team already.
usage: Use to leave a warzone. Teleports you back to the lobby. Must be in team already.
Ex - /leave
team:
description: War> Team chat.
usage: Team chat.
usage: Team chat.
Ex - /team <message>
# Warzone maker commands (must have the 'war.*' permission or be added as a zone-maker in /plugins/War/war.txt
# 1- Battle-related commands
nextbattle:
description: War> Warzone blocks are restored, teams are respawned but score remains unaffected.
usage: Warzone blocks are restored, teams are respawned but score remains unaffected. Provide a zone name if not standing in warzone or lobby.
usage: Warzone blocks are restored, teams are respawned but score remains unaffected. Provide a zone name if not standing in warzone or lobby.
Ex - /nextbattle [zone-name]
# 2- Warzone creation commands
setzone:
description: War> Use to create a warzone. Lobby is created and blocks are saved when the second corner is set.
usage: Use to create a warzone. Lobby is created and blocks are saved when the second corner is set. Warzones must be at least 10 blocks wide in all directions.
Ex -
Ex -
==Wand Cuboid mode==>
1) /setzone <zone-name> to get wooden sword,
2) Left-click to select or move corner1,
3) Right-click to select or move corner2.
1) /setzone <zone-name> to get wooden sword,
2) Left-click to select or move corner1,
3) Right-click to select or move corner2.
Turn off wand by dropping the wooden sword.
==Wandless Cuboid mode==>
/setzone <zone-name> <corner1/corner2/c1/c2/pos1/pos2>
==Wandless Cuboid mode==>
/setzone <zone-name> <corner1/corner2/c1/c2/pos1/pos2>
savezone:
description: War> Persists changes made to the warzone since the last save. Config can be set with named parameters.
usage: Persists changes made to the warzone since the last save. Config can be set with named parameters. Provide a zone name if not standing in warzone or lobby.
Ex -
/savezone [zone-name] => Basic save - name optional if standing inside,
/savezone [zone-name] lifepool:8 teamsize:5 maxscore:7 autoassign:on outline:off ff:on blockheads:off spawnstyle:<big/flat/small> unbreakable:on nocreatures:on disabled:on,
/savezone [zone-name] loadout:default => sets the respawn inventory to your current items,
Ex -
/savezone [zone-name] => Basic save - name optional if standing inside,
/savezone [zone-name] lifepool:8 teamsize:5 maxscore:7 autoassign:on outline:off ff:on blockheads:off spawnstyle:<big/flat/small> unbreakable:on nocreatures:on disabled:on,
/savezone [zone-name] loadout:default => sets the respawn inventory to your current items,
/savezone [zone-name] reward:default => sets the winner's reward to your current items.
setzonelobby:
description: War> Creates or changes the position of the warzone lobby.
@ -111,8 +111,8 @@ commands:
/setteam <diamond/iron/gold/white/orange/magenta/blue/green/pink/gray/purple/navy/brown/darkgreen/red/black>
setmonument:
description: War> Creates or moves a monument.
usage: Creates or moves a monument. Must be standing in warzone.
Ex -
usage: Creates or moves a monument. Must be standing in warzone.
Ex -
/setmonument <monument-name>
setteamflag:
description: War> Creates/moves a team flag post for CTF.
@ -122,13 +122,18 @@ commands:
resetzone:
description: War> Reloads zone blocks from disk. Everyone is teleported back to the lobby.
usage: Reloads zone blocks from disk. Everyone is teleported back to the lobby. Provide a zone name if not standing in warzone or lobby.
Ex -
Ex -
/resetzone [zone-name]
deletezone:
description: War> Deletes the zone, resets all blocks.
usage: Deletes the zone after resetting all blocks. Provide a zone name if not standing in warzone or lobby.
Ex -
/deletezone [zone-name]
renamezone:
description: War> Renames the zone
usage: Renames the zone. Provide a zone name if not standing in warzone or lobby.
Ex -
/renamezone [zone-name] <new-name>
deleteteam:
description: War> Deletes the team. Team must exist.
usage: Deletes the team. Team must exist. Provide a zone name if not standing in warzone or lobby.
@ -169,7 +174,7 @@ commands:
setwarhub:
description: War> Create or moves a wall of portals. One portal per warzone. Warzones get a portal back to the warhub.
usage: Create or moves a wall of portals. One portal per warzone. Warzones get a portal back to the warhub.
Ex -
Ex -
/setwarhub
deletewarhub:
description: War> Deletes the warhub if it exists. Resets all warzone lobbies.
@ -180,7 +185,7 @@ commands:
unloadwar:
description: War> Disables the War plugin.
usage: Disables the War plugin.
Ex -
Ex -
/unloadwar
loadwar:
description: War> Enables the War plugin.
@ -205,12 +210,12 @@ commands:
/setwarconfig loadout:default => sets the respawn inventory to your current items,
/setwarconfig reward:default => sets the winner's reward to your current items,
/setwarconfig rallypoint:<warzone-name> => changes when players get teleported at the end of a match for that zone, useful for chaining warzones together in a sequence, or preventing players from rejoining immediately
# Fallback
war:
description: War> Short War help. Can also be used as a prefix for all War commands as a fallback if they conflict with other plugins.
usage: War is on. Please pick your battle. Try /warhub, /zones and /zone. Further instructions at war.tommytony.com/instructions.
The /war command can be used as a prefix to all other command as a fallback if they conflict with other plugins. Ex -
usage: War is on. Please pick your battle. Try /warhub, /zones and /zone. Further instructions at war.tommytony.com/instructions.
The /war command can be used as a prefix to all other command as a fallback if they conflict with other plugins. Ex -
/war,
/war setzone <zone-name>,
/war warhub,

View File

@ -34,65 +34,65 @@ commands:
# Player commands
warzones:
description: War> Lists the warzones on the server. Each warzone is an independent arena.
usage: Lists the warzones on the server. Each warzone is an independent arena.
usage: Lists the warzones on the server. Each warzone is an independent arena.
Ex - /warzones
zones:
description: War> Shortcut for /warzones.
usage: Lists the warzones on the server. Each warzone is an independent arena.
usage: Lists the warzones on the server. Each warzone is an independent arena.
Ex - /zones
warzone:
description: War> Teleports you to the specified warzone's lobby.
usage: Teleports you to the specified warzone's lobby.
usage: Teleports you to the specified warzone's lobby.
Ex - /warzone <zone-name>
zone:
description: War> Shortcut for /warzone.
usage: Teleports you to the specified warzone's lobby.
usage: Teleports you to the specified warzone's lobby.
Ex - /zone <zone-name>
warhub:
description: War> Teleports you to the warhub, if it exists. The warhub offers portals to reach each warzone on the server.
usage: Teleports you to the warhub, if it exists.
usage: Teleports you to the warhub, if it exists.
Ex - /warhub
teams:
description: War> Lists the teams in the warzone.
usage: Lists the teams in the warzone. Use zone name when outside warzone.
usage: Lists the teams in the warzone. Use zone name when outside warzone.
Ex - /teams [zone-name]
join:
description: War> Use to change teams. Also used instead of walking in the team gate in the lobby.
usage: Use to change teams. Also used instead of walking in the team gate in the lobby. Must be standing in warzone or lobby.
usage: Use to change teams. Also used instead of walking in the team gate in the lobby. Must be standing in warzone or lobby.
Ex - /join <team-color>
leave:
description: War> Use to leave a warzone. Teleports you back to the lobby.
usage: Use to leave a warzone. Teleports you back to the lobby. Must be in team already.
usage: Use to leave a warzone. Teleports you back to the lobby. Must be in team already.
Ex - /leave
team:
description: War> Team chat.
usage: Team chat.
usage: Team chat.
Ex - /team <message>
# Warzone maker commands (must have the 'war.*' permission or be added as a zone-maker in /plugins/War/war.txt
# 1- Battle-related commands
nextbattle:
description: War> Warzone blocks are restored, teams are respawned but score remains unaffected.
usage: Warzone blocks are restored, teams are respawned but score remains unaffected. Provide a zone name if not standing in warzone or lobby.
usage: Warzone blocks are restored, teams are respawned but score remains unaffected. Provide a zone name if not standing in warzone or lobby.
Ex - /nextbattle [zone-name]
# 2- Warzone creation commands
setzone:
description: War> Use to create a warzone. Lobby is created and blocks are saved when the second corner is set.
usage: Use to create a warzone. Lobby is created and blocks are saved when the second corner is set. Warzones must be at least 10 blocks wide in all directions.
Ex -
Ex -
==Wand Cuboid mode==>
1) /setzone <zone-name> to get wooden sword,
2) Left-click to select or move corner1,
3) Right-click to select or move corner2.
1) /setzone <zone-name> to get wooden sword,
2) Left-click to select or move corner1,
3) Right-click to select or move corner2.
Turn off wand by dropping the wooden sword.
==Wandless Cuboid mode==>
/setzone <zone-name> <corner1/corner2/c1/c2/pos1/pos2>
==Wandless Cuboid mode==>
/setzone <zone-name> <corner1/corner2/c1/c2/pos1/pos2>
savezone:
description: War> Persists changes made to the warzone since the last save. Config can be set with named parameters.
usage: Persists changes made to the warzone since the last save. Config can be set with named parameters. Provide a zone name if not standing in warzone or lobby.
Ex -
/savezone [zone-name] => Basic save - name optional if standing inside,
/savezone [zone-name] lifepool:8 teamsize:5 maxscore:7 autoassign:on outline:off ff:on blockheads:off spawnstyle:<big/flat/small> unbreakable:on nocreatures:on disabled:on,
/savezone [zone-name] loadout:default => sets the respawn inventory to your current items,
Ex -
/savezone [zone-name] => Basic save - name optional if standing inside,
/savezone [zone-name] lifepool:8 teamsize:5 maxscore:7 autoassign:on outline:off ff:on blockheads:off spawnstyle:<big/flat/small> unbreakable:on nocreatures:on disabled:on,
/savezone [zone-name] loadout:default => sets the respawn inventory to your current items,
/savezone [zone-name] reward:default => sets the winner's reward to your current items.
setzonelobby:
description: War> Creates or changes the position of the warzone lobby.
@ -111,8 +111,8 @@ commands:
/setteam <diamond/iron/gold/white/orange/magenta/blue/green/pink/gray/purple/navy/brown/darkgreen/red/black>
setmonument:
description: War> Creates or moves a monument.
usage: Creates or moves a monument. Must be standing in warzone.
Ex -
usage: Creates or moves a monument. Must be standing in warzone.
Ex -
/setmonument <monument-name>
setteamflag:
description: War> Creates/moves a team flag post for CTF.
@ -122,13 +122,18 @@ commands:
resetzone:
description: War> Reloads zone blocks from disk. Everyone is teleported back to the lobby.
usage: Reloads zone blocks from disk. Everyone is teleported back to the lobby. Provide a zone name if not standing in warzone or lobby.
Ex -
Ex -
/resetzone [zone-name]
deletezone:
description: War> Deletes the zone, resets all blocks.
usage: Deletes the zone after resetting all blocks. Provide a zone name if not standing in warzone or lobby.
Ex -
/deletezone [zone-name]
renamezone:
description: War> Renames the zone
usage: Renames the zone. Provide a zone name if not standing in warzone or lobby.
Ex -
/renamezone [zone-name] <new-name>
deleteteam:
description: War> Deletes the team. Team must exist.
usage: Deletes the team. Team must exist. Provide a zone name if not standing in warzone or lobby.
@ -169,7 +174,7 @@ commands:
setwarhub:
description: War> Create or moves a wall of portals. One portal per warzone. Warzones get a portal back to the warhub.
usage: Create or moves a wall of portals. One portal per warzone. Warzones get a portal back to the warhub.
Ex -
Ex -
/setwarhub
deletewarhub:
description: War> Deletes the warhub if it exists. Resets all warzone lobbies.
@ -180,7 +185,7 @@ commands:
unloadwar:
description: War> Disables the War plugin.
usage: Disables the War plugin.
Ex -
Ex -
/unloadwar
loadwar:
description: War> Enables the War plugin.
@ -205,12 +210,12 @@ commands:
/setwarconfig loadout:default => sets the respawn inventory to your current items,
/setwarconfig reward:default => sets the winner's reward to your current items,
/setwarconfig rallypoint:<warzone-name> => changes when players get teleported at the end of a match for that zone, useful for chaining warzones together in a sequence, or preventing players from rejoining immediately
# Fallback
war:
description: War> Short War help. Can also be used as a prefix for all War commands as a fallback if they conflict with other plugins.
usage: War is on. Please pick your battle. Try /warhub, /zones and /zone. Further instructions at war.tommytony.com/instructions.
The /war command can be used as a prefix to all other command as a fallback if they conflict with other plugins. Ex -
usage: War is on. Please pick your battle. Try /warhub, /zones and /zone. Further instructions at war.tommytony.com/instructions.
The /war command can be used as a prefix to all other command as a fallback if they conflict with other plugins. Ex -
/war,
/war setzone <zone-name>,
/war warhub,