Command cleanup. Stub commands for material and teleport added.
This commit is contained in:
parent
e34276b729
commit
64a7ac50fa
@ -94,9 +94,7 @@ public class Plugin extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
// Save gates
|
||||
gatesManager.saveGatesToDisk();
|
||||
|
||||
log("Disabled");
|
||||
}
|
||||
|
||||
@ -122,18 +120,14 @@ public class Plugin extends JavaPlugin {
|
||||
commands.add(new CommandRemove());
|
||||
commands.add(new CommandLocation());
|
||||
commands.add(new CommandExit());
|
||||
commands.add(new CommandOpen());
|
||||
commands.add(new CommandTriggerOpen());
|
||||
commands.add(new CommandRename());
|
||||
commands.add(new CommandClose());
|
||||
commands.add(new CommandList());
|
||||
commands.add(new CommandInfo());
|
||||
commands.add(new CommandHide());
|
||||
commands.add(new CommandUnhide());
|
||||
commands.add(new CommandExitOpen());
|
||||
commands.add(new CommandNearby());
|
||||
commands.add(new CommandAllowRiding());
|
||||
commands.add(new CommandDenyRiding());
|
||||
|
||||
commands.add(new CommandTriggerVehicles());
|
||||
commands.add(new CommandMaterial());
|
||||
commands.add(new CommandTeleport());
|
||||
|
||||
// Register events
|
||||
this.registerEventListeners();
|
||||
@ -168,7 +162,6 @@ public class Plugin extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------- //
|
||||
// Commands
|
||||
// -------------------------------------------- //
|
||||
@ -184,7 +177,6 @@ public class Plugin extends JavaPlugin {
|
||||
return this.baseCommand;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||
List<String> parameters = new ArrayList<>(Arrays.asList(args));
|
||||
@ -192,7 +184,6 @@ public class Plugin extends JavaPlugin {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private void handleCommand(CommandSender sender, List<String> parameters) {
|
||||
if (parameters.size() == 0) {
|
||||
this.commands.get(0).execute(sender, parameters);
|
||||
@ -220,7 +211,6 @@ public class Plugin extends JavaPlugin {
|
||||
log(Level.INFO, msg);
|
||||
}
|
||||
|
||||
|
||||
public static void log(Level level, String msg) {
|
||||
Logger.getLogger("Minecraft").log(level, "[" + instance.getDescription().getFullName() + "] " + msg);
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ import de.craftinc.gates.util.TextUtil;
|
||||
|
||||
public abstract class BaseCommand {
|
||||
PermissionController permissionController;
|
||||
GatesManager gatesManager;
|
||||
|
||||
List<String> aliases = new ArrayList<>();
|
||||
List<String> requiredParameters = new ArrayList<>();
|
||||
@ -58,6 +59,7 @@ public abstract class BaseCommand {
|
||||
}
|
||||
|
||||
public BaseCommand() {
|
||||
gatesManager = Plugin.getPlugin().getGatesManager();
|
||||
permissionController = Plugin.getPlugin().getPermissionController();
|
||||
}
|
||||
|
||||
@ -69,14 +71,14 @@ public abstract class BaseCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.senderMustBePlayer) {
|
||||
if (sender instanceof Player) {
|
||||
this.player = (Player)sender;
|
||||
}
|
||||
|
||||
this.perform();
|
||||
|
||||
if (this.shouldPersistToDisk && getSaveOnChanges()) {
|
||||
Plugin.getPlugin().getGatesManager().saveGatesToDisk();
|
||||
gatesManager.saveGatesToDisk();
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,12 +95,10 @@ public abstract class BaseCommand {
|
||||
}
|
||||
|
||||
boolean setGateUsingParameter(String param) {
|
||||
GatesManager gateManager = Plugin.getPlugin().getGatesManager();
|
||||
|
||||
if (!gateManager.gateExists(param)) {
|
||||
if (!gatesManager.gateExists(param)) {
|
||||
return false;
|
||||
} else {
|
||||
gate = gateManager.getGateWithId(param);
|
||||
gate = gatesManager.getGateWithId(param);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,53 +0,0 @@
|
||||
/* Craft Inc. Gates
|
||||
Copyright (C) 2011-2013 Craft Inc. Gates Team (see AUTHORS.txt)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program (LGPLv3). If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.craftinc.gates.commands;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import de.craftinc.gates.controllers.PermissionController;
|
||||
import de.craftinc.gates.util.GateBlockChangeSender;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import de.craftinc.gates.Plugin;
|
||||
|
||||
public class CommandClose extends BaseCommand {
|
||||
|
||||
public CommandClose() {
|
||||
aliases.add("close");
|
||||
aliases.add("c");
|
||||
|
||||
requiredParameters.add("id");
|
||||
helpDescription = "Closes a gate to prevent players from using it.";
|
||||
requiredPermission = PermissionController.permissionManage;
|
||||
needsPermissionAtCurrentLocation = false;
|
||||
shouldPersistToDisk = true;
|
||||
senderMustBePlayer = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
try {
|
||||
gate.setOpen(false);
|
||||
GateBlockChangeSender.updateGateBlocks(gate);
|
||||
sendMessage(ChatColor.GREEN + "The gate was closed.");
|
||||
} catch (Exception e) {
|
||||
sendMessage(ChatColor.RED + "Opening the gate failed! See server log for more information");
|
||||
Plugin.log(Level.WARNING, e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
/* Craft Inc. Gates
|
||||
Copyright (C) 2011-2013 Craft Inc. Gates Team (see AUTHORS.txt)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program (LGPLv3). If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.craftinc.gates.commands;
|
||||
|
||||
import de.craftinc.gates.controllers.PermissionController;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
public class CommandDenyRiding extends BaseCommand {
|
||||
|
||||
public CommandDenyRiding() {
|
||||
aliases.add("denyRiding");
|
||||
aliases.add("dr");
|
||||
|
||||
requiredParameters.add("id");
|
||||
helpDescription = "Deny players to travel while riding.";
|
||||
requiredPermission = PermissionController.permissionManage;
|
||||
needsPermissionAtCurrentLocation = false;
|
||||
shouldPersistToDisk = true;
|
||||
senderMustBePlayer = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void perform() {
|
||||
gate.setAllowsVehicles(false);
|
||||
sendMessage(ChatColor.GREEN + "Traveling while riding is now disabled for this gate.");
|
||||
}
|
||||
}
|
@ -30,25 +30,20 @@ public class CommandExit extends BaseCommand {
|
||||
public CommandExit() {
|
||||
aliases.add("exit");
|
||||
aliases.add("e");
|
||||
|
||||
requiredParameters.add("id");
|
||||
|
||||
helpDescription = "Change exit of location.";
|
||||
|
||||
requiredPermission = PermissionController.permissionManage;
|
||||
|
||||
needsPermissionAtCurrentLocation = true;
|
||||
shouldPersistToDisk = true;
|
||||
senderMustBePlayer = true;
|
||||
}
|
||||
|
||||
|
||||
public void perform() {
|
||||
try {
|
||||
Location oldExit = gate.getExit();
|
||||
gate.setExit(player.getLocation());
|
||||
sendMessage(ChatColor.GREEN + "The exit of gate '" + gate.getId() + "' is now where you stand.");
|
||||
Plugin.getPlugin().getGatesManager().handleGateExitChange(gate, oldExit);
|
||||
gatesManager.handleGateExitChange(gate, oldExit);
|
||||
} catch (Exception e) {
|
||||
GateBlockChangeSender.updateGateBlocks(gate);
|
||||
sendMessage(ChatColor.RED + "Setting the exit for the gate failed! See server log for more information");
|
||||
|
@ -1,76 +0,0 @@
|
||||
/* Craft Inc. Gates
|
||||
Copyright (C) 2011-2013 Craft Inc. Gates Team (see AUTHORS.txt)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program (LGPLv3). If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.craftinc.gates.commands;
|
||||
|
||||
|
||||
import de.craftinc.gates.controllers.PermissionController;
|
||||
import de.craftinc.gates.Plugin;
|
||||
import de.craftinc.gates.util.GateBlockChangeSender;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
|
||||
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 = PermissionController.permissionManage;
|
||||
needsPermissionAtCurrentLocation = true;
|
||||
shouldPersistToDisk = true;
|
||||
senderMustBePlayer = true;
|
||||
}
|
||||
|
||||
|
||||
public void perform() {
|
||||
try {
|
||||
Location oldExit = gate.getExit();
|
||||
gate.setExit(player.getLocation());
|
||||
sendMessage(ChatColor.GREEN + "The exit of gate '" + gate.getId() + "' is now where you stand.");
|
||||
Plugin.getPlugin().getGatesManager().handleGateExitChange(gate, oldExit);
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
@ -17,90 +17,50 @@
|
||||
package de.craftinc.gates.commands;
|
||||
|
||||
import de.craftinc.gates.controllers.PermissionController;
|
||||
import de.craftinc.gates.util.TextUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandHelp extends BaseCommand {
|
||||
|
||||
private static List<List<String>> helpPages;
|
||||
|
||||
static {
|
||||
// sort the usage strings
|
||||
List<String> allUsageStrings = new ArrayList<>();
|
||||
|
||||
allUsageStrings.add(new CommandHelp().getUsageTemplate(true));
|
||||
allUsageStrings.add(new CommandNew().getUsageTemplate(true));
|
||||
allUsageStrings.add(new CommandRemove().getUsageTemplate(true));
|
||||
allUsageStrings.add(new CommandLocation().getUsageTemplate(true));
|
||||
allUsageStrings.add(new CommandExit().getUsageTemplate(true));
|
||||
allUsageStrings.add(new CommandOpen().getUsageTemplate(true));
|
||||
allUsageStrings.add(new CommandRename().getUsageTemplate(true));
|
||||
allUsageStrings.add(new CommandClose().getUsageTemplate(true));
|
||||
allUsageStrings.add(new CommandList().getUsageTemplate(true));
|
||||
allUsageStrings.add(new CommandInfo().getUsageTemplate(true));
|
||||
allUsageStrings.add(new CommandHide().getUsageTemplate(true));
|
||||
allUsageStrings.add(new CommandUnhide().getUsageTemplate(true));
|
||||
allUsageStrings.add(new CommandExitOpen().getUsageTemplate(true));
|
||||
allUsageStrings.add(new CommandNearby().getUsageTemplate(true));
|
||||
|
||||
Collections.sort(allUsageStrings);
|
||||
|
||||
|
||||
// put 5 commands on one page
|
||||
helpPages = new ArrayList<>();
|
||||
|
||||
while (!allUsageStrings.isEmpty()) {
|
||||
int toIndex = allUsageStrings.size() >= 6 ? 5 : allUsageStrings.size();
|
||||
List<String> currentHelpPage = new ArrayList<>(allUsageStrings.subList(0, toIndex));
|
||||
helpPages.add(currentHelpPage);
|
||||
|
||||
allUsageStrings.removeAll(currentHelpPage);
|
||||
}
|
||||
}
|
||||
|
||||
private static List<String> help;
|
||||
|
||||
public CommandHelp() {
|
||||
aliases.add("help");
|
||||
aliases.add("?");
|
||||
|
||||
optionalParameters.add("page");
|
||||
helpDescription = "prints this help page";
|
||||
|
||||
requiredPermission = PermissionController.permissionInfo;
|
||||
|
||||
hasGateParam = false;
|
||||
needsPermissionAtCurrentLocation = false;
|
||||
shouldPersistToDisk = false;
|
||||
senderMustBePlayer = false;
|
||||
}
|
||||
|
||||
|
||||
public void perform() {
|
||||
int page;
|
||||
|
||||
if (parameters.size() > 0) {
|
||||
try {
|
||||
page = Integer.parseInt(parameters.get(0));
|
||||
} catch (NumberFormatException e) {
|
||||
// wasn't an integer
|
||||
page = 1;
|
||||
}
|
||||
} else {
|
||||
page = 1;
|
||||
sendMessage(getHelp());
|
||||
}
|
||||
|
||||
sendMessage(TextUtil.titleSize("Craft Inc. Gates Help (" + page + "/" + helpPages.size() + ")"));
|
||||
|
||||
page -= 1;
|
||||
if (page < 0 || page >= helpPages.size()) {
|
||||
sendMessage("This page does not exist");
|
||||
return;
|
||||
private List<String> getHelp() {
|
||||
if (help == null) {
|
||||
help = Arrays.asList(
|
||||
new CommandHelp().getUsageTemplate(true),
|
||||
new CommandNew().getUsageTemplate(true),
|
||||
new CommandRemove().getUsageTemplate(true),
|
||||
new CommandLocation().getUsageTemplate(true),
|
||||
new CommandExit().getUsageTemplate(true),
|
||||
new CommandTriggerOpen().getUsageTemplate(true),
|
||||
new CommandRename().getUsageTemplate(true),
|
||||
new CommandList().getUsageTemplate(true),
|
||||
new CommandInfo().getUsageTemplate(true),
|
||||
new CommandNearby().getUsageTemplate(true),
|
||||
new CommandTriggerVehicles().getUsageTemplate(true),
|
||||
new CommandTeleport().getUsageTemplate(true),
|
||||
new CommandMaterial().getUsageTemplate(true)
|
||||
);
|
||||
Collections.sort(help);
|
||||
}
|
||||
|
||||
sendMessage(helpPages.get(page));
|
||||
return help;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,57 +0,0 @@
|
||||
/* Craft Inc. Gates
|
||||
Copyright (C) 2011-2013 Craft Inc. Gates Team (see AUTHORS.txt)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program (LGPLv3). If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.craftinc.gates.commands;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import de.craftinc.gates.controllers.PermissionController;
|
||||
import de.craftinc.gates.util.GateBlockChangeSender;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import de.craftinc.gates.Plugin;
|
||||
|
||||
|
||||
public class CommandHide extends BaseCommand {
|
||||
|
||||
public CommandHide() {
|
||||
aliases.add("hide");
|
||||
aliases.add("h");
|
||||
|
||||
requiredParameters.add("id");
|
||||
|
||||
helpDescription = "Makes a gate NOT consist of gate blocks while open.";
|
||||
|
||||
requiredPermission = PermissionController.permissionManage;
|
||||
|
||||
needsPermissionAtCurrentLocation = false;
|
||||
shouldPersistToDisk = true;
|
||||
senderMustBePlayer = false;
|
||||
}
|
||||
|
||||
|
||||
public void perform() {
|
||||
try {
|
||||
gate.setHidden(true);
|
||||
GateBlockChangeSender.updateGateBlocks(gate);
|
||||
sendMessage(ChatColor.GREEN + "The gate '" + gate.getId() + "' is now hidden.");
|
||||
} catch (Exception e) {
|
||||
sendMessage(ChatColor.RED + "Hiding the gate failed! See server log for more information");
|
||||
Plugin.log(Level.WARNING, e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@ -32,20 +32,15 @@ public class CommandInfo extends BaseCommand {
|
||||
public CommandInfo() {
|
||||
aliases.add("info");
|
||||
aliases.add("i");
|
||||
|
||||
optionalParameters.add("id");
|
||||
|
||||
helpDescription = "Print detailed information about a certain or the closest gate.";
|
||||
|
||||
requiredPermission = PermissionController.permissionInfo;
|
||||
|
||||
needsPermissionAtCurrentLocation = false;
|
||||
shouldPersistToDisk = false;
|
||||
senderMustBePlayer = false;
|
||||
hasGateParam = false;
|
||||
}
|
||||
|
||||
|
||||
public void perform() {
|
||||
if (this.parameters.size() > 0) {
|
||||
|
||||
@ -64,7 +59,7 @@ public class CommandInfo extends BaseCommand {
|
||||
}
|
||||
|
||||
Player p = (Player) this.sender;
|
||||
this.gate = Plugin.getPlugin().getGatesManager().getNearestGate(p.getLocation());
|
||||
this.gate = gatesManager.getNearestGate(p.getLocation());
|
||||
|
||||
if (!this.hasPermission() || this.gate == null) {
|
||||
sendMessage(ChatColor.RED + "There is either no gate nearby or you do not have permission to " + this.helpDescription.toLowerCase());
|
||||
|
@ -30,7 +30,7 @@ import de.craftinc.gates.util.TextUtil;
|
||||
|
||||
public class CommandList extends BaseCommand {
|
||||
|
||||
private static final int linesPerPage = 10;
|
||||
private static final int linesPerPage = 15;
|
||||
|
||||
/* this is actually not true. the font used by Minecraft is not
|
||||
monospaced. but there seems to be no (easy) way to calculate
|
||||
@ -64,7 +64,7 @@ public class CommandList extends BaseCommand {
|
||||
}
|
||||
|
||||
if (page > allPages.size() || page < 1) {
|
||||
sendMessage(ChatColor.RED + "The requested page is not availible");
|
||||
sendMessage(ChatColor.RED + "The requested page is not available");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -148,7 +148,7 @@ public class CommandList extends BaseCommand {
|
||||
* Method for getting a collection of gates the player is allowed to see.
|
||||
*/
|
||||
private Collection<Gate> getAllGates() {
|
||||
Collection<Gate> gates = Plugin.getPlugin().getGatesManager().allGates();
|
||||
Collection<Gate> gates = gatesManager.allGates();
|
||||
// create a copy since we cannot iterate over a collection while modifying it!
|
||||
Collection<Gate> gatesCopy = new ArrayList<>(gates);
|
||||
|
||||
|
@ -62,9 +62,9 @@ public class CommandLocation extends BaseLocationCommand {
|
||||
sendMessage(ChatColor.GREEN + "The location of '" + gate.getId() + "' is now at your current location.");
|
||||
} catch (Exception e) {
|
||||
sendMessage(ChatColor.RED + "There seems to be no frame at your new location! The gate got closed!" + ChatColor.AQUA + " You should build a frame now and execute:");
|
||||
sendMessage(new CommandOpen().getUsageTemplate(true));
|
||||
sendMessage(new CommandTriggerOpen().getUsageTemplate(true));
|
||||
} finally {
|
||||
Plugin.getPlugin().getGatesManager().handleGateLocationChange(gate, oldLocation, oldGateBlockLocations, oldFrameBlocks);
|
||||
gatesManager.handleGateLocationChange(gate, oldLocation, oldGateBlockLocations, oldFrameBlocks);
|
||||
GateBlockChangeSender.updateGateBlocks(gate);
|
||||
}
|
||||
}
|
||||
|
23
src/de/craftinc/gates/commands/CommandMaterial.java
Normal file
23
src/de/craftinc/gates/commands/CommandMaterial.java
Normal file
@ -0,0 +1,23 @@
|
||||
package de.craftinc.gates.commands;
|
||||
|
||||
import de.craftinc.gates.controllers.PermissionController;
|
||||
|
||||
public class CommandMaterial extends BaseCommand {
|
||||
|
||||
public CommandMaterial() {
|
||||
aliases.add("material");
|
||||
aliases.add("m");
|
||||
|
||||
requiredParameters.add("id");
|
||||
|
||||
senderMustBePlayer = false;
|
||||
hasGateParam = true;
|
||||
helpDescription = "Change the material of a gate";
|
||||
requiredPermission = PermissionController.permissionManage;
|
||||
needsPermissionAtCurrentLocation = false;
|
||||
shouldPersistToDisk = true;
|
||||
}
|
||||
|
||||
public void perform() {
|
||||
}
|
||||
}
|
@ -25,8 +25,7 @@ public class CommandNearby extends BaseLocationCommand {
|
||||
}
|
||||
|
||||
public void perform() {
|
||||
GatesManager manager = Plugin.getPlugin().getGatesManager();
|
||||
Set<Gate> nearbyGates = manager.getNearbyGates(player.getLocation().getChunk());
|
||||
Set<Gate> nearbyGates = gatesManager.getNearbyGates(player.getLocation().getChunk());
|
||||
|
||||
if (nearbyGates == null) {
|
||||
player.sendMessage("There are no gates near you!");
|
||||
|
@ -28,6 +28,7 @@ public class CommandNew extends BaseLocationCommand {
|
||||
|
||||
public CommandNew() {
|
||||
aliases.add("new");
|
||||
aliases.add("create");
|
||||
aliases.add("n");
|
||||
|
||||
requiredParameters.add("id");
|
||||
@ -43,7 +44,6 @@ public class CommandNew extends BaseLocationCommand {
|
||||
|
||||
public void perform() {
|
||||
String id = parameters.get(0);
|
||||
GatesManager gatesManager = Plugin.getPlugin().getGatesManager();
|
||||
|
||||
if (gatesManager.gateExists(id)) {
|
||||
sendMessage(ChatColor.RED + "Creating the gate failed! " + "A gate with the supplied id already exists!");
|
||||
|
@ -43,7 +43,7 @@ public class CommandRemove extends BaseCommand {
|
||||
}
|
||||
|
||||
public void perform() {
|
||||
Plugin.getPlugin().getGatesManager().handleDeletion(gate);
|
||||
gatesManager.handleDeletion(gate);
|
||||
GateBlockChangeSender.updateGateBlocks(gate, true);
|
||||
sendMessage(ChatColor.GREEN + "Gate with id '" + gate.getId() + "' was deleted.");
|
||||
}
|
||||
|
@ -30,23 +30,16 @@ public class CommandRename extends BaseCommand {
|
||||
|
||||
hasGateParam = true;
|
||||
senderMustBePlayer = false;
|
||||
|
||||
requiredParameters.add("current name");
|
||||
requiredParameters.add("new name");
|
||||
|
||||
helpDescription = "Changes the id of a gate.";
|
||||
|
||||
requiredPermission = PermissionController.permissionManage;
|
||||
|
||||
needsPermissionAtCurrentLocation = false;
|
||||
shouldPersistToDisk = true;
|
||||
senderMustBePlayer = false;
|
||||
}
|
||||
|
||||
|
||||
public void perform() {
|
||||
String newId = parameters.get(1);
|
||||
GatesManager gatesManager = Plugin.getPlugin().getGatesManager();
|
||||
|
||||
if (gatesManager.gateExists(newId)) {
|
||||
sendMessage(ChatColor.RED + "Cannot rename " + gate.getId() + ". There is already a gate named " + newId + ".");
|
||||
|
23
src/de/craftinc/gates/commands/CommandTeleport.java
Normal file
23
src/de/craftinc/gates/commands/CommandTeleport.java
Normal file
@ -0,0 +1,23 @@
|
||||
package de.craftinc.gates.commands;
|
||||
|
||||
import de.craftinc.gates.controllers.PermissionController;
|
||||
|
||||
public class CommandTeleport extends BaseCommand {
|
||||
|
||||
public CommandTeleport() {
|
||||
aliases.add("teleport");
|
||||
aliases.add("t");
|
||||
|
||||
requiredParameters.add("id");
|
||||
|
||||
senderMustBePlayer = true;
|
||||
hasGateParam = true;
|
||||
helpDescription = "Teleport to the location of a gate";
|
||||
requiredPermission = PermissionController.permissionManage;
|
||||
needsPermissionAtCurrentLocation = false;
|
||||
shouldPersistToDisk = false;
|
||||
}
|
||||
|
||||
public void perform() {
|
||||
}
|
||||
}
|
@ -22,14 +22,14 @@ import org.bukkit.ChatColor;
|
||||
|
||||
import de.craftinc.gates.Plugin;
|
||||
|
||||
public class CommandOpen extends BaseCommand {
|
||||
public class CommandTriggerOpen extends BaseCommand {
|
||||
|
||||
public CommandOpen() {
|
||||
aliases.add("open");
|
||||
public CommandTriggerOpen() {
|
||||
aliases.add("triggerOpen");
|
||||
aliases.add("o");
|
||||
|
||||
requiredParameters.add("id");
|
||||
helpDescription = "Open a gate so players can use it.";
|
||||
helpDescription = "Open/close a gate.";
|
||||
requiredPermission = PermissionController.permissionManage;
|
||||
|
||||
needsPermissionAtCurrentLocation = false;
|
||||
@ -39,20 +39,15 @@ public class CommandOpen extends BaseCommand {
|
||||
|
||||
public void perform() {
|
||||
try {
|
||||
boolean needsGateManagerUpdate = false;
|
||||
|
||||
if (gate.getGateBlockLocations().isEmpty()) {
|
||||
needsGateManagerUpdate = true;
|
||||
if (!gate.isOpen() && gate.getExit() == null && player != null) {
|
||||
gate.setExit(player.getLocation());
|
||||
sendMessage(ChatColor.GREEN + "The exit of gate '" + gate.getId() + "' is now where you stand.");
|
||||
}
|
||||
|
||||
gate.setOpen(true);
|
||||
gate.setOpen(gate.isOpen());
|
||||
|
||||
GateBlockChangeSender.updateGateBlocks(gate);
|
||||
|
||||
if (needsGateManagerUpdate) {
|
||||
Plugin.getPlugin().getGatesManager().handleGateLocationChange(gate, null, null, null);
|
||||
}
|
||||
|
||||
gatesManager.handleGateLocationChange(gate, null, null, null);
|
||||
sendMessage(ChatColor.GREEN + "The gate was opened.");
|
||||
} catch (Exception e) {
|
||||
sendMessage(ChatColor.RED + e.getMessage());
|
@ -19,25 +19,29 @@ package de.craftinc.gates.commands;
|
||||
import de.craftinc.gates.controllers.PermissionController;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
public class CommandAllowRiding extends BaseCommand {
|
||||
public class CommandTriggerVehicles extends BaseCommand {
|
||||
|
||||
public CommandAllowRiding() {
|
||||
aliases.add("allowRiding");
|
||||
aliases.add("ar");
|
||||
public CommandTriggerVehicles() {
|
||||
aliases.add("vehicles");
|
||||
aliases.add("v");
|
||||
|
||||
requiredParameters.add("id");
|
||||
|
||||
helpDescription = "Allow players to travel while riding.";
|
||||
helpDescription = "Allow/deny players to travel while riding.";
|
||||
requiredPermission = PermissionController.permissionManage;
|
||||
needsPermissionAtCurrentLocation = false;
|
||||
shouldPersistToDisk = true;
|
||||
|
||||
senderMustBePlayer = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void perform() {
|
||||
gate.setAllowsVehicles(true);
|
||||
gate.setAllowsVehicles(gate.getAllowsVehicles());
|
||||
|
||||
if (gate.getAllowsVehicles()) {
|
||||
sendMessage(ChatColor.GREEN + "Traveling while riding is now enabled for this gate.");
|
||||
} else {
|
||||
sendMessage(ChatColor.GREEN + "Traveling while riding is now disabled for this gate.");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
/* Craft Inc. Gates
|
||||
Copyright (C) 2011-2013 Craft Inc. Gates Team (see AUTHORS.txt)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program (LGPLv3). If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.craftinc.gates.commands;
|
||||
|
||||
import de.craftinc.gates.controllers.PermissionController;
|
||||
import de.craftinc.gates.util.GateBlockChangeSender;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
public class CommandUnhide extends BaseCommand {
|
||||
|
||||
public CommandUnhide() {
|
||||
aliases.add("unhide");
|
||||
aliases.add("u");
|
||||
|
||||
requiredParameters.add("id");
|
||||
helpDescription = "Make that gate visible";
|
||||
requiredPermission = PermissionController.permissionManage;
|
||||
needsPermissionAtCurrentLocation = false;
|
||||
shouldPersistToDisk = true;
|
||||
senderMustBePlayer = false;
|
||||
}
|
||||
|
||||
public void perform() {
|
||||
try {
|
||||
gate.setHidden(false);
|
||||
GateBlockChangeSender.updateGateBlocks(gate);
|
||||
sendMessage(ChatColor.GREEN + "The gate " + gate.getId() + " is now visible.");
|
||||
} catch (Exception e) {
|
||||
sendMessage(ChatColor.RED + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user