Added an exitopen
command. This command will set the exit location of a gate and open it afterwards.
This commit is contained in:
parent
42b293e6bc
commit
5ace80e6d1
@ -142,6 +142,7 @@ public class Plugin extends JavaPlugin
|
||||
commands.add(new CommandInfo());
|
||||
commands.add(new CommandHide());
|
||||
commands.add(new CommandUnhide());
|
||||
commands.add(new CommandExitOpen());
|
||||
|
||||
|
||||
// Register events
|
||||
|
64
src/de/craftinc/gates/commands/CommandExitOpen.java
Normal file
64
src/de/craftinc/gates/commands/CommandExitOpen.java
Normal file
@ -0,0 +1,64 @@
|
||||
package de.craftinc.gates.commands;
|
||||
|
||||
|
||||
import de.craftinc.gates.Plugin;
|
||||
import de.craftinc.gates.util.GateBlockChangeSender;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class CommandExitOpen extends BaseCommand
|
||||
{
|
||||
public CommandExitOpen()
|
||||
{
|
||||
aliases.add("exitopen");
|
||||
aliases.add("eo");
|
||||
|
||||
requiredParameters.add("id");
|
||||
|
||||
helpDescription = "Change exit of location and open that gate afterwards.";
|
||||
|
||||
requiredPermission = Plugin.permissionManage;
|
||||
|
||||
needsPermissionAtCurrentLocation = true;
|
||||
shouldPersistToDisk = true;
|
||||
senderMustBePlayer = true;
|
||||
}
|
||||
|
||||
|
||||
public void perform()
|
||||
{
|
||||
try
|
||||
{
|
||||
gate.setExit(player.getLocation());
|
||||
sendMessage(ChatColor.GREEN + "The exit of gate '" + gate.getId() + "' is now where you stand.");
|
||||
|
||||
try {
|
||||
boolean needsGateManagerUpdate = false;
|
||||
|
||||
if (gate.getGateBlockLocations().isEmpty()) {
|
||||
needsGateManagerUpdate = true;
|
||||
}
|
||||
|
||||
gate.setOpen(true);
|
||||
|
||||
GateBlockChangeSender.updateGateBlocks(gate);
|
||||
|
||||
if (needsGateManagerUpdate) {
|
||||
Plugin.getPlugin().getGatesManager().handleGateLocationChange(gate, null, null, null);
|
||||
}
|
||||
|
||||
sendMessage(ChatColor.GREEN + "The gate was opened.");
|
||||
}
|
||||
catch (Exception e) {
|
||||
sendMessage(ChatColor.RED + e.getMessage());
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
GateBlockChangeSender.updateGateBlocks(gate);
|
||||
sendMessage(ChatColor.RED + "Setting the exit for the gate failed! This gate is now closed! (See server log for more information.)");
|
||||
Plugin.log(Level.WARNING, e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@ -44,6 +44,7 @@ public class CommandHelp extends BaseCommand
|
||||
allUsageStrings.add( new CommandInfo().getUsageTemplate(true, true) );
|
||||
allUsageStrings.add( new CommandHide().getUsageTemplate(true, true) );
|
||||
allUsageStrings.add( new CommandUnhide().getUsageTemplate(true, true) );
|
||||
allUsageStrings.add( new CommandExitOpen().getUsageTemplate(true, true) );
|
||||
|
||||
Collections.sort(allUsageStrings);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user