Worked a little more on cell creation, no longer have to provide a cell

name and when that happens we give it one ourself.
This commit is contained in:
graywolf336 2013-12-09 13:05:31 -06:00
parent 3643627b7d
commit 0272a3a241
2 changed files with 71 additions and 61 deletions

View File

@ -1,61 +1,69 @@
package com.graywolf336.jail.command.commands; package com.graywolf336.jail.command.commands;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.graywolf336.jail.JailManager; import com.graywolf336.jail.JailManager;
import com.graywolf336.jail.beans.Cell; import com.graywolf336.jail.beans.Cell;
import com.graywolf336.jail.beans.Jail; import com.graywolf336.jail.beans.Jail;
import com.graywolf336.jail.command.Command; import com.graywolf336.jail.command.Command;
import com.graywolf336.jail.command.CommandInfo; import com.graywolf336.jail.command.CommandInfo;
@CommandInfo( @CommandInfo(
maxArgs = 2, maxArgs = 2,
minimumArgs = 2, minimumArgs = 1,
needsPlayer = true, needsPlayer = true,
pattern = "jailcreatecells|jcc", pattern = "jailcreatecells|jcc",
permission = "jail.command.jailcreatecells", permission = "jail.command.jailcreatecells",
usage = "/jailcellcreate [jail] [cellname]" usage = "/jailcellcreate [jail] (cellname)"
) )
public class CellCreateCommand implements Command { public class CellCreateCommand implements Command {
public boolean execute(JailManager jm, CommandSender sender, String... args) { public boolean execute(JailManager jm, CommandSender sender, String... args) {
Player player = (Player) sender; Player player = (Player) sender;
String name = player.getName(); String name = player.getName();
String jail = args[0].toLowerCase(); String jail = args[0].toLowerCase();
String cell = args[1]; String cell = "";
//Check if the player is currently creating something else //Only get the cell name they provide if they provide it
if(jm.isCreatingSomething(name)) { if(args.length >= 2) {
String message = jm.getStepMessage(name); cell = args[1];
if(!message.isEmpty()) { }
player.sendMessage(ChatColor.RED + message);
}else { //Check if the player is currently creating something else
player.sendMessage(ChatColor.RED + "You're already creating something else, please finish it or cancel."); if(jm.isCreatingSomething(name)) {
} String message = jm.getStepMessage(name);
}else { if(!message.isEmpty()) {
//Not creating anything, so let them create some cells. player.sendMessage(ChatColor.RED + message);
if(jm.isValidJail(jail)) { }else {
Jail j = jm.getJail(jail); player.sendMessage(ChatColor.RED + "You're already creating something else, please finish it or cancel.");
Cell c = j.getCell(cell); }
}else {
//No cell found //Not creating anything, so let them create some cells.
if(c == null) { if(jm.isValidJail(jail)) {
if(jm.addCreatingCell(name, jail, cell)) { Jail j = jm.getJail(jail);
jm.getCellCreationSteps().startStepping(player);
}else { //If they didn't provide a cell name, let's provide one ourself.
player.sendMessage(ChatColor.RED + "Appears you're creating a cell or something went wrong on our side."); if(cell.isEmpty()) cell = "cell_n" + (j.getCellCount() + 1);
} Cell c = j.getCell(cell);
}else {
player.sendMessage(ChatColor.RED + "There's already a cell with the name '" + cell + "', please pick a new one or remove that cell."); //No cell found
} if(c == null) {
}else { if(jm.addCreatingCell(name, jail, cell)) {
player.sendMessage(ChatColor.RED + "No such jail found by the name of '" + jail + "'."); jm.getCellCreationSteps().startStepping(player);
} }else {
} player.sendMessage(ChatColor.RED + "Appears you're creating a cell or something went wrong on our side.");
}
return true; }else {
} player.sendMessage(ChatColor.RED + "There's already a cell with the name '" + cell + "', please pick a new one or remove that cell.");
}
} }else {
player.sendMessage(ChatColor.RED + "No such jail found by the name of '" + jail + "'.");
}
}
return true;
}
}

View File

@ -115,7 +115,9 @@ public class CellCreationSteps {
player.sendMessage(ChatColor.GREEN + "Chest selected."); player.sendMessage(ChatColor.GREEN + "Chest selected.");
player.sendMessage(ChatColor.AQUA + "----------------------------------------"); player.sendMessage(ChatColor.AQUA + "----------------------------------------");
}else { }else {
player.sendMessage(ChatColor.RED + "---------- Jail Cell Creation ----------");
player.sendMessage(ChatColor.RED + "Chest must be a double chest, chest not selected"); player.sendMessage(ChatColor.RED + "Chest must be a double chest, chest not selected");
player.sendMessage(ChatColor.RED + "----------------------------------------");
return; return;
} }
}else { }else {