mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2025-04-11 22:46:14 +02:00
Ported SetSpawn.
Extraced common in game only command error message
This commit is contained in:
parent
5c144f31c2
commit
2ea45c8219
@ -45,6 +45,7 @@ import com.onarandombox.MultiverseCore.command.CommandManager;
|
||||
import com.onarandombox.MultiverseCore.command.commands.CoordCommand;
|
||||
import com.onarandombox.MultiverseCore.command.commands.HelpCommand;
|
||||
import com.onarandombox.MultiverseCore.command.commands.ListCommand;
|
||||
import com.onarandombox.MultiverseCore.command.commands.SetSpawnCommand;
|
||||
import com.onarandombox.MultiverseCore.command.commands.WhoCommand;
|
||||
import com.onarandombox.MultiverseCore.command.commands.TeleportCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.MVCoord;
|
||||
@ -53,7 +54,6 @@ import com.onarandombox.MultiverseCore.commands.MVImport;
|
||||
import com.onarandombox.MultiverseCore.commands.MVModify;
|
||||
import com.onarandombox.MultiverseCore.commands.MVReload;
|
||||
import com.onarandombox.MultiverseCore.commands.MVRemove;
|
||||
import com.onarandombox.MultiverseCore.commands.MVSetSpawn;
|
||||
import com.onarandombox.MultiverseCore.commands.MVSpawn;
|
||||
import com.onarandombox.MultiverseCore.configuration.DefaultConfiguration;
|
||||
import com.onarandombox.utils.DebugLog;
|
||||
@ -295,6 +295,7 @@ public class MultiverseCore extends JavaPlugin {
|
||||
commandManager.addCommand(new TeleportCommand(this));
|
||||
commandManager.addCommand(new ListCommand(this));
|
||||
commandManager.addCommand(new WhoCommand(this));
|
||||
commandManager.addCommand(new SetSpawnCommand(this));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -307,7 +308,7 @@ public class MultiverseCore extends JavaPlugin {
|
||||
commands.put("mvmodify", new MVModify(this));
|
||||
// commands.put("mvtp", new TeleportCommand(this));
|
||||
// commands.put("mvlist", new ListCommand(this));
|
||||
commands.put("mvsetspawn", new MVSetSpawn(this));
|
||||
// commands.put("mvsetspawn", new SetSpawnCommand(this));
|
||||
commands.put("mvspawn", new MVSpawn(this));
|
||||
commands.put("mvcoord", new MVCoord(this));
|
||||
// commands.put("mvwho", new WhoCommand(this));
|
||||
|
@ -16,6 +16,8 @@ public abstract class BaseCommand {
|
||||
protected int minArgs;
|
||||
protected int maxArgs;
|
||||
protected List<String> identifiers;
|
||||
|
||||
public final String IN_GAME_COMMAND_MSG = "This command needs to be used as a Player in game.";
|
||||
|
||||
public BaseCommand(MultiverseCore plugin) {
|
||||
this.identifiers = new ArrayList<String>();
|
||||
|
@ -28,6 +28,7 @@ public class HelpCommand extends BaseCommand {
|
||||
maxArgs = 1;
|
||||
identifiers.add("mv help");
|
||||
identifiers.add("mv");
|
||||
identifiers.add("mvhelp");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,21 +1,27 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
package com.onarandombox.MultiverseCore.command.commands;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVCommandHandler;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.command.BaseCommand;
|
||||
|
||||
public class MVSetSpawn extends MVCommandHandler {
|
||||
|
||||
public MVSetSpawn(MultiverseCore plugin) {
|
||||
public class SetSpawnCommand extends BaseCommand {
|
||||
|
||||
public SetSpawnCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
name = "Set World Spawn";
|
||||
description = "Sets the spawn for the current world.";
|
||||
usage = "/mvsetspawn";
|
||||
minArgs = 0;
|
||||
maxArgs = 0;
|
||||
identifiers.add("mvsetspawn");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean perform(CommandSender sender, String[] args) {
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
// TODO: Permissions
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
@ -24,9 +30,9 @@ public class MVSetSpawn extends MVCommandHandler {
|
||||
w.setSpawnLocation(l.getBlockX(), l.getBlockY(), l.getBlockZ());
|
||||
p.sendMessage(w.getName() + " - Spawn set to X: " + l.getBlockX() + " Y: " + l.getBlockY() + " Z: " + l.getBlockZ());
|
||||
} else {
|
||||
sender.sendMessage("Must be used in game");
|
||||
sender.sendMessage(IN_GAME_COMMAND_MSG);
|
||||
}
|
||||
return false;
|
||||
return ;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,7 +1,5 @@
|
||||
package com.onarandombox.MultiverseCore.command.commands;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -14,7 +12,6 @@ import com.onarandombox.utils.Destination;
|
||||
import com.onarandombox.utils.DestinationType;
|
||||
|
||||
public class TeleportCommand extends BaseCommand {
|
||||
private final Logger log = Logger.getLogger("Minecraft");
|
||||
private MVTeleport playerTeleporter;
|
||||
|
||||
public TeleportCommand(MultiverseCore plugin) {
|
||||
@ -51,7 +48,7 @@ public class TeleportCommand extends BaseCommand {
|
||||
}
|
||||
|
||||
} else {
|
||||
sender.sendMessage("This command needs to be used from a Player.");
|
||||
sender.sendMessage(IN_GAME_COMMAND_MSG);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ public class WhoCommand extends BaseCommand {
|
||||
super(plugin);
|
||||
name = "Who";
|
||||
description = "States who is in what world";
|
||||
usage = "/mvwho [WORLD]";
|
||||
usage = "/mvwho" + ChatColor.GOLD + " [WORLD]";
|
||||
minArgs = 0;
|
||||
maxArgs = 1;
|
||||
identifiers.add("mvwho");
|
||||
@ -35,10 +35,6 @@ public class WhoCommand extends BaseCommand {
|
||||
}
|
||||
|
||||
List<World> worlds = new ArrayList<World>();
|
||||
// No longer needed
|
||||
// if (args.length > 1) {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
if (args.length > 0) {
|
||||
World world = plugin.getServer().getWorld(args[0].toString());
|
||||
|
Loading…
Reference in New Issue
Block a user