From 0272a3a241d07b12fe7e22a78f780e79bd89c4f6 Mon Sep 17 00:00:00 2001 From: graywolf336 Date: Mon, 9 Dec 2013 13:05:31 -0600 Subject: [PATCH] Worked a little more on cell creation, no longer have to provide a cell name and when that happens we give it one ourself. --- .../command/commands/CellCreateCommand.java | 130 ++++++++++-------- .../jail/steps/CellCreationSteps.java | 2 + 2 files changed, 71 insertions(+), 61 deletions(-) diff --git a/src/main/java/com/graywolf336/jail/command/commands/CellCreateCommand.java b/src/main/java/com/graywolf336/jail/command/commands/CellCreateCommand.java index 2ebe255..ee8da70 100644 --- a/src/main/java/com/graywolf336/jail/command/commands/CellCreateCommand.java +++ b/src/main/java/com/graywolf336/jail/command/commands/CellCreateCommand.java @@ -1,61 +1,69 @@ -package com.graywolf336.jail.command.commands; - -import org.bukkit.ChatColor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.graywolf336.jail.JailManager; -import com.graywolf336.jail.beans.Cell; -import com.graywolf336.jail.beans.Jail; -import com.graywolf336.jail.command.Command; -import com.graywolf336.jail.command.CommandInfo; - -@CommandInfo( - maxArgs = 2, - minimumArgs = 2, - needsPlayer = true, - pattern = "jailcreatecells|jcc", - permission = "jail.command.jailcreatecells", - usage = "/jailcellcreate [jail] [cellname]" - ) -public class CellCreateCommand implements Command { - - public boolean execute(JailManager jm, CommandSender sender, String... args) { - Player player = (Player) sender; - String name = player.getName(); - String jail = args[0].toLowerCase(); - String cell = args[1]; - - //Check if the player is currently creating something else - if(jm.isCreatingSomething(name)) { - String message = jm.getStepMessage(name); - if(!message.isEmpty()) { - player.sendMessage(ChatColor.RED + message); - }else { - player.sendMessage(ChatColor.RED + "You're already creating something else, please finish it or cancel."); - } - }else { - //Not creating anything, so let them create some cells. - if(jm.isValidJail(jail)) { - Jail j = jm.getJail(jail); - Cell c = j.getCell(cell); - - //No cell found - if(c == null) { - if(jm.addCreatingCell(name, jail, cell)) { - jm.getCellCreationSteps().startStepping(player); - }else { - player.sendMessage(ChatColor.RED + "Appears you're creating a cell or something went wrong on our side."); - } - }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; - } - -} +package com.graywolf336.jail.command.commands; + +import org.bukkit.ChatColor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.graywolf336.jail.JailManager; +import com.graywolf336.jail.beans.Cell; +import com.graywolf336.jail.beans.Jail; +import com.graywolf336.jail.command.Command; +import com.graywolf336.jail.command.CommandInfo; + +@CommandInfo( + maxArgs = 2, + minimumArgs = 1, + needsPlayer = true, + pattern = "jailcreatecells|jcc", + permission = "jail.command.jailcreatecells", + usage = "/jailcellcreate [jail] (cellname)" + ) +public class CellCreateCommand implements Command { + + public boolean execute(JailManager jm, CommandSender sender, String... args) { + Player player = (Player) sender; + String name = player.getName(); + String jail = args[0].toLowerCase(); + String cell = ""; + + //Only get the cell name they provide if they provide it + if(args.length >= 2) { + cell = args[1]; + } + + //Check if the player is currently creating something else + if(jm.isCreatingSomething(name)) { + String message = jm.getStepMessage(name); + if(!message.isEmpty()) { + player.sendMessage(ChatColor.RED + message); + }else { + player.sendMessage(ChatColor.RED + "You're already creating something else, please finish it or cancel."); + } + }else { + //Not creating anything, so let them create some cells. + if(jm.isValidJail(jail)) { + Jail j = jm.getJail(jail); + + //If they didn't provide a cell name, let's provide one ourself. + if(cell.isEmpty()) cell = "cell_n" + (j.getCellCount() + 1); + Cell c = j.getCell(cell); + + //No cell found + if(c == null) { + if(jm.addCreatingCell(name, jail, cell)) { + jm.getCellCreationSteps().startStepping(player); + }else { + player.sendMessage(ChatColor.RED + "Appears you're creating a cell or something went wrong on our side."); + } + }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; + } + +} diff --git a/src/main/java/com/graywolf336/jail/steps/CellCreationSteps.java b/src/main/java/com/graywolf336/jail/steps/CellCreationSteps.java index 98b3a3e..8890b5c 100644 --- a/src/main/java/com/graywolf336/jail/steps/CellCreationSteps.java +++ b/src/main/java/com/graywolf336/jail/steps/CellCreationSteps.java @@ -115,7 +115,9 @@ public class CellCreationSteps { player.sendMessage(ChatColor.GREEN + "Chest selected."); player.sendMessage(ChatColor.AQUA + "----------------------------------------"); }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 + "----------------------------------------"); return; } }else {