diff --git a/src/org/mcteam/ancientgates/commands/BaseCommand.java b/src/org/mcteam/ancientgates/commands/BaseCommand.java index e80d0b6..6ca9495 100644 --- a/src/org/mcteam/ancientgates/commands/BaseCommand.java +++ b/src/org/mcteam/ancientgates/commands/BaseCommand.java @@ -8,7 +8,6 @@ import org.bukkit.entity.Player; import org.mcteam.ancientgates.Gate; import org.mcteam.ancientgates.Plugin; -import org.mcteam.ancientgates.Conf; import org.mcteam.ancientgates.util.TextUtil; public class BaseCommand @@ -67,7 +66,7 @@ public class BaseCommand } public void sendMessage(String message) { - sender.sendMessage(Conf.colorSystem+message); + sender.sendMessage(message); } public void sendMessage(List messages) { @@ -126,11 +125,11 @@ public class BaseCommand public String getUsageTemplate(boolean withColor, boolean withDescription) { String ret = ""; - if (withColor) { - ret += Conf.colorCommand; - } +// if (withColor) { +// ret += Conf.colorCommand; +// } - ret += "/" + Plugin.instance.getBaseCommand()+ " " +TextUtil.implode(this.getAliases(), ",")+" "; + ret += "/" + Plugin.instance.getBaseCommand() + " " + TextUtil.implode(this.getAliases(), ",")+" "; List parts = new ArrayList(); @@ -142,15 +141,15 @@ public class BaseCommand parts.add("*["+optionalParameter+"]"); } - if (withColor) { - ret += Conf.colorParameter; - } +// if (withColor) { +// ret += Conf.colorParameter; +// } ret += TextUtil.implode(parts, " "); - if (withDescription) { - ret += " "+Conf.colorSystem + this.helpDescription; - } +// if (withDescription) { +// ret += " "+Conf.colorSystem + this.helpDescription; +// } return ret; } diff --git a/src/org/mcteam/ancientgates/commands/CommandClose.java b/src/org/mcteam/ancientgates/commands/CommandClose.java index 18146e6..ca95489 100644 --- a/src/org/mcteam/ancientgates/commands/CommandClose.java +++ b/src/org/mcteam/ancientgates/commands/CommandClose.java @@ -1,7 +1,6 @@ package org.mcteam.ancientgates.commands; import org.bukkit.command.CommandSender; -import org.mcteam.ancientgates.Gate; public class CommandClose extends BaseCommand { @@ -17,9 +16,8 @@ public class CommandClose extends BaseCommand @Override public void perform() { - gate.close(); + gate.setOpen(false); sendMessage("The gate was closed."); - Gate.save(); } diff --git a/src/org/mcteam/ancientgates/commands/CommandCreate.java b/src/org/mcteam/ancientgates/commands/CommandCreate.java index 040c01e..2c5c7a9 100644 --- a/src/org/mcteam/ancientgates/commands/CommandCreate.java +++ b/src/org/mcteam/ancientgates/commands/CommandCreate.java @@ -31,7 +31,6 @@ public class CommandCreate extends BaseCommand Gate.create(id); sendMessage("Gate with id \"" + id + "\" was created. Now you should:"); sendMessage(new CommandSetFrom().getUsageTemplate(true, true)); - Gate.save(); } diff --git a/src/org/mcteam/ancientgates/commands/CommandCreateSetFrom.java b/src/org/mcteam/ancientgates/commands/CommandCreateSetFrom.java index c82a2e3..3283662 100644 --- a/src/org/mcteam/ancientgates/commands/CommandCreateSetFrom.java +++ b/src/org/mcteam/ancientgates/commands/CommandCreateSetFrom.java @@ -7,7 +7,6 @@ import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.command.CommandSender; -import org.mcteam.ancientgates.Conf; import org.mcteam.ancientgates.Gate; import org.mcteam.ancientgates.util.FloodUtil; @@ -56,17 +55,17 @@ public class CommandCreateSetFrom extends BaseCommand if (gateBlocks == null) { - sendMessage("Could not set from! Your portal is too large.\nMax size is: " + Conf.getGateMaxArea() + " Blocks."); + sendMessage("Could not set from! Your portal is too large.\nMax size is: " /*+ Conf.getGateMaxArea()*/ + " Blocks."); return; } if (playerBlock.getType() == Material.AIR) { - gate.setFrom(player.getLocation()); + gate.setLocation(player.getLocation()); } else if (upBlock.getType() == Material.AIR) { - gate.setFrom(playerUpLocation); + gate.setLocation(playerUpLocation); } else { @@ -76,8 +75,6 @@ public class CommandCreateSetFrom extends BaseCommand sendMessage("From location for gate \""+gate.getId()+"\" is now where you stand."); sendMessage("Your gate includes " + gateBlocks.size() + " Blocks."); - - Gate.save(); } diff --git a/src/org/mcteam/ancientgates/commands/CommandDelete.java b/src/org/mcteam/ancientgates/commands/CommandDelete.java index f4a4fcd..f28e3cb 100644 --- a/src/org/mcteam/ancientgates/commands/CommandDelete.java +++ b/src/org/mcteam/ancientgates/commands/CommandDelete.java @@ -18,10 +18,9 @@ public class CommandDelete extends BaseCommand { public void perform() { - gate.close(); + gate.setOpen(false); sendMessage("Gate with id \"" + gate.getId() + "\" was deleted."); Gate.delete(gate.getId()); - Gate.save(); } diff --git a/src/org/mcteam/ancientgates/commands/CommandHide.java b/src/org/mcteam/ancientgates/commands/CommandHide.java index 34db62b..ac8e3a8 100644 --- a/src/org/mcteam/ancientgates/commands/CommandHide.java +++ b/src/org/mcteam/ancientgates/commands/CommandHide.java @@ -1,7 +1,6 @@ package org.mcteam.ancientgates.commands; import org.bukkit.command.CommandSender; -import org.mcteam.ancientgates.Gate; public class CommandHide extends BaseCommand { @@ -19,8 +18,6 @@ public class CommandHide extends BaseCommand { gate.setHidden(true); sendMessage("The gate " + gate.getId() + " is now hidden."); - - Gate.save(); } @Override diff --git a/src/org/mcteam/ancientgates/commands/CommandInfo.java b/src/org/mcteam/ancientgates/commands/CommandInfo.java index 5d89818..9a8fb75 100644 --- a/src/org/mcteam/ancientgates/commands/CommandInfo.java +++ b/src/org/mcteam/ancientgates/commands/CommandInfo.java @@ -2,7 +2,6 @@ package org.mcteam.ancientgates.commands; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; -import org.mcteam.ancientgates.Gate; public class CommandInfo extends BaseCommand @@ -36,18 +35,15 @@ public class CommandInfo extends BaseCommand sendMessage(openHiddenMessage); - if (gate.getFrom() != null) - sendMessage(ChatColor.GREEN + "'from' location: " + ChatColor.YELLOW + "( " + gate.getFrom().getBlockX() + " | " + gate.getFrom().getBlockY() + " | " + gate.getFrom().getBlockZ() + " ) in " + gate.getFrom().getWorld().getName()); + if (gate.getLocation() != null) + sendMessage(ChatColor.GREEN + "'from' location: " + ChatColor.YELLOW + "( " + gate.getLocation().getBlockX() + " | " + gate.getLocation().getBlockY() + " | " + gate.getLocation().getBlockZ() + " ) in " + gate.getLocation().getWorld().getName()); else sendMessage(ChatColor.GREEN + "this gate has no 'from' location"); - if (gate.getTo() != null) - sendMessage(ChatColor.GREEN + "'to' location: " + ChatColor.YELLOW + "( " + gate.getTo().getBlockX() + " | " + gate.getTo().getBlockY() + " | " + gate.getTo().getBlockZ() + " ) in " + gate.getTo().getWorld().getName()); + if (gate.getExit() != null) + sendMessage(ChatColor.GREEN + "'to' location: " + ChatColor.YELLOW + "( " + gate.getExit().getBlockX() + " | " + gate.getExit().getBlockY() + " | " + gate.getExit().getBlockZ() + " ) in " + gate.getExit().getWorld().getName()); else sendMessage(ChatColor.GREEN + "this gate has no 'to' location"); - - - Gate.save(); } diff --git a/src/org/mcteam/ancientgates/commands/CommandList.java b/src/org/mcteam/ancientgates/commands/CommandList.java index 87d212a..ad0d3d3 100644 --- a/src/org/mcteam/ancientgates/commands/CommandList.java +++ b/src/org/mcteam/ancientgates/commands/CommandList.java @@ -8,10 +8,11 @@ import java.util.List; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; -import org.mcteam.ancientgates.Conf; + import org.mcteam.ancientgates.Gate; import org.mcteam.ancientgates.util.TextUtil; + public class CommandList extends BaseCommand { public CommandList() @@ -29,11 +30,11 @@ public class CommandList extends BaseCommand protected String intToTitleString(int i) { if ( i < 26 ) - return Conf.colorMember + "" + (char)(i+65) + ":"; + return ChatColor.GREEN + "" + (char)(i+65) + ":"; else if ( i == 26 ) - return Conf.colorMember + "0 - 9:"; + return ChatColor.GREEN + "0 - 9:"; else - return Conf.colorMember + "!@#$:"; + return ChatColor.GREEN + "!@#$:"; } @@ -211,8 +212,6 @@ public class CommandList extends BaseCommand else sendMessage(messages); } - - Gate.save(); } diff --git a/src/org/mcteam/ancientgates/commands/CommandOpen.java b/src/org/mcteam/ancientgates/commands/CommandOpen.java index f7264a8..fc617bc 100644 --- a/src/org/mcteam/ancientgates/commands/CommandOpen.java +++ b/src/org/mcteam/ancientgates/commands/CommandOpen.java @@ -2,7 +2,6 @@ package org.mcteam.ancientgates.commands; import org.bukkit.Material; import org.bukkit.command.CommandSender; -import org.mcteam.ancientgates.Gate; public class CommandOpen extends BaseCommand { @@ -15,30 +14,30 @@ public class CommandOpen extends BaseCommand { } public void perform() { - if (gate.getFrom() == null) { + if (gate.getLocation() == null) { sendMessage("You must set the from location first. To fix that:"); sendMessage(new CommandSetFrom().getUsageTemplate(true, true)); return; } - if (gate.getTo() == null) { + if (gate.getExit() == null) { sendMessage("Sure, but note that this gate does not point anywhere :P"); sendMessage("To fix that: " + new CommandSetTo().getUsageTemplate(true, true)); } - if (gate.getFrom().getBlock().getType() != Material.AIR) { + if (gate.getLocation().getBlock().getType() != Material.AIR) { sendMessage("The gate could not open. The from location is not air."); return; } - if (gate.open()) { + gate.setOpen(true); + + if (gate.isOpen()) { sendMessage("The gate was opened."); } else { sendMessage("Failed to open the gate. Have you built a frame?"); sendMessage("More info here: " + new CommandHelp().getUsageTemplate(true, true)); } - - Gate.save(); } diff --git a/src/org/mcteam/ancientgates/commands/CommandRename.java b/src/org/mcteam/ancientgates/commands/CommandRename.java index 5a84bd1..3b39b11 100644 --- a/src/org/mcteam/ancientgates/commands/CommandRename.java +++ b/src/org/mcteam/ancientgates/commands/CommandRename.java @@ -26,19 +26,15 @@ public class CommandRename extends BaseCommand public void perform() { String newId = parameters.get(1); - String oldId = gate.getId(); - if (Gate.exists(newId)) - { - sendMessage("Cannot rename " + oldId + ". There is already a gate named " + newId + "."); - return; + try { + Gate.rename(gate, newId); + } + catch (Exception e) { + sendMessage("Cannot rename " + gate.getId() + ". There is already a gate named " + newId + "."); } - Gate.rename(gate, newId); - - sendMessage("Gate " + oldId + " is now known as " + newId + "."); - - Gate.save(); + sendMessage("Gate " + gate.getId() + " is now known as " + newId + "."); } diff --git a/src/org/mcteam/ancientgates/commands/CommandSetFrom.java b/src/org/mcteam/ancientgates/commands/CommandSetFrom.java index e0605f5..035cd82 100644 --- a/src/org/mcteam/ancientgates/commands/CommandSetFrom.java +++ b/src/org/mcteam/ancientgates/commands/CommandSetFrom.java @@ -1,15 +1,16 @@ package org.mcteam.ancientgates.commands; import java.util.Set; + import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.command.CommandSender; -import org.mcteam.ancientgates.Conf; -import org.mcteam.ancientgates.Gate; + import org.mcteam.ancientgates.util.FloodUtil; + public class CommandSetFrom extends BaseCommand { @@ -40,17 +41,17 @@ public class CommandSetFrom extends BaseCommand if (gateBlocks == null) { - sendMessage("There is no portal here, or your portal is too large.\nMax size is: " + Conf.getGateMaxArea() + " Blocks."); + sendMessage("There is no portal here, or your portal is too large.\nMax size is: " /*+ Conf.getGateMaxArea()*/ + " Blocks."); return; } if (playerBlock.getType() == Material.AIR) { - gate.setFrom(player.getLocation()); + gate.setLocation(player.getLocation()); } else if (upBlock.getType() == Material.AIR) { - gate.setFrom(playerUpLocation); + gate.setLocation(playerUpLocation); } else { @@ -60,8 +61,6 @@ public class CommandSetFrom extends BaseCommand sendMessage("From location for gate \""+gate.getId()+"\" is now where you stand."); sendMessage("Your gate includes " + gateBlocks.size() + " Blocks."); - - Gate.save(); } diff --git a/src/org/mcteam/ancientgates/commands/CommandSetTo.java b/src/org/mcteam/ancientgates/commands/CommandSetTo.java index 7bb0c9f..b226980 100644 --- a/src/org/mcteam/ancientgates/commands/CommandSetTo.java +++ b/src/org/mcteam/ancientgates/commands/CommandSetTo.java @@ -1,7 +1,6 @@ package org.mcteam.ancientgates.commands; import org.bukkit.command.CommandSender; -import org.mcteam.ancientgates.Gate; public class CommandSetTo extends BaseCommand { @@ -15,10 +14,8 @@ public class CommandSetTo extends BaseCommand { } public void perform() { - gate.setTo(player.getLocation()); + gate.setExit(player.getLocation()); sendMessage("To location for gate \""+gate.getId()+"\" is now where you stand."); - - Gate.save(); } diff --git a/src/org/mcteam/ancientgates/commands/CommandUnhide.java b/src/org/mcteam/ancientgates/commands/CommandUnhide.java index 3cfa1e6..3fa7178 100644 --- a/src/org/mcteam/ancientgates/commands/CommandUnhide.java +++ b/src/org/mcteam/ancientgates/commands/CommandUnhide.java @@ -1,7 +1,6 @@ package org.mcteam.ancientgates.commands; import org.bukkit.command.CommandSender; -import org.mcteam.ancientgates.Gate; public class CommandUnhide extends BaseCommand { @@ -17,12 +16,14 @@ public class CommandUnhide extends BaseCommand public void perform() { - if (gate.setHidden(false)) - sendMessage("The gate " + gate.getId() + " is no longer hidden."); - else - sendMessage("Failed to unhide the gate. Does the portal have a frame?"); + boolean isOpen = gate.isOpen(); - Gate.save(); + gate.setHidden(false); + sendMessage("The gate " + gate.getId() + " is no longer hidden."); + + if (isOpen != gate.isOpen()) { + sendMessage("The Portal is now closed. Does the portal have a frame?"); + } }