mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2025-01-23 08:41:21 +01:00
Import MVSpawn, close #11
This commit is contained in:
parent
7c595bd58b
commit
1971b8fc4e
@ -48,13 +48,13 @@ import com.onarandombox.MultiverseCore.command.commands.HelpCommand;
|
||||
import com.onarandombox.MultiverseCore.command.commands.ListCommand;
|
||||
import com.onarandombox.MultiverseCore.command.commands.CreateCommand;
|
||||
import com.onarandombox.MultiverseCore.command.commands.ImportCommand;
|
||||
import com.onarandombox.MultiverseCore.command.commands.SpawnCommand;
|
||||
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.MVModify;
|
||||
import com.onarandombox.MultiverseCore.commands.MVReload;
|
||||
import com.onarandombox.MultiverseCore.commands.MVRemove;
|
||||
import com.onarandombox.MultiverseCore.commands.MVSpawn;
|
||||
import com.onarandombox.MultiverseCore.configuration.DefaultConfiguration;
|
||||
import com.onarandombox.utils.DebugLog;
|
||||
import com.onarandombox.utils.Messaging;
|
||||
@ -298,6 +298,7 @@ public class MultiverseCore extends JavaPlugin {
|
||||
commandManager.addCommand(new SetSpawnCommand(this));
|
||||
commandManager.addCommand(new CreateCommand(this));
|
||||
commandManager.addCommand(new ImportCommand(this));
|
||||
commandManager.addCommand(new SpawnCommand(this));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -311,7 +312,7 @@ public class MultiverseCore extends JavaPlugin {
|
||||
// commands.put("mvtp", new TeleportCommand(this));
|
||||
// commands.put("mvlist", new ListCommand(this));
|
||||
// commands.put("mvsetspawn", new SetSpawnCommand(this));
|
||||
commands.put("mvspawn", new MVSpawn(this));
|
||||
//commands.put("mvspawn", new SpawnCommand(this));
|
||||
// commands.put("mvcoord", new MVCoord(this));
|
||||
// commands.put("mvwho", new WhoCommand(this));
|
||||
commands.put("mvreload", new MVReload(this));
|
||||
|
@ -0,0 +1,51 @@
|
||||
package com.onarandombox.MultiverseCore.command.commands;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.command.BaseCommand;
|
||||
|
||||
public class SpawnCommand extends BaseCommand {
|
||||
|
||||
public SpawnCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
name = "Spawn";
|
||||
description = "Transports the player to the that player's current world Spawn Point.";
|
||||
usage = "/mvspawn" + ChatColor.GOLD + " [PLAYER]";
|
||||
minArgs = 0;
|
||||
maxArgs = 1;
|
||||
identifiers.add("mvspawn");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
// TODO: Permissions
|
||||
Player commandSender = null;
|
||||
if (sender instanceof Player) {
|
||||
commandSender = (Player) sender;
|
||||
}
|
||||
if (args.length == 1) {
|
||||
Player target = plugin.getServer().getPlayer(args[0]);
|
||||
if (target != null) {
|
||||
target.sendMessage("Teleporting to this world's spawn...");
|
||||
target.teleport(target.getWorld().getSpawnLocation());
|
||||
if (commandSender != null) {
|
||||
target.sendMessage("You were teleported by: " + ChatColor.YELLOW + commandSender.getName());
|
||||
} else {
|
||||
target.sendMessage("You were teleported by: " + ChatColor.LIGHT_PURPLE + "the console");
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(args[0] + " is not logged on right now!");
|
||||
}
|
||||
} else {
|
||||
if (commandSender != null) {
|
||||
commandSender.sendMessage("Teleporting to this world's spawn...");
|
||||
commandSender.teleport(commandSender.getWorld().getSpawnLocation());
|
||||
} else {
|
||||
sender.sendMessage("From the console, you must provide a PLAYER.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -13,7 +13,7 @@ import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.command.BaseCommand;
|
||||
|
||||
public class WhoCommand extends BaseCommand {
|
||||
|
||||
|
||||
public WhoCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
name = "Who";
|
||||
@ -23,9 +23,9 @@ public class WhoCommand extends BaseCommand {
|
||||
maxArgs = 1;
|
||||
identifiers.add("mvwho");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
// If this command was sent from a Player then we need to check Permissions
|
||||
if (sender instanceof Player) {
|
||||
if (!(plugin.ph.has(((Player) sender), "multiverse.who"))) {
|
||||
@ -33,9 +33,9 @@ public class WhoCommand extends BaseCommand {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
List<World> worlds = new ArrayList<World>();
|
||||
|
||||
|
||||
if (args.length > 0) {
|
||||
World world = plugin.getServer().getWorld(args[0].toString());
|
||||
if (world != null) {
|
||||
@ -47,16 +47,18 @@ public class WhoCommand extends BaseCommand {
|
||||
} else {
|
||||
worlds = plugin.getServer().getWorlds();
|
||||
}
|
||||
|
||||
|
||||
for (World world : worlds) {
|
||||
ChatColor color = ChatColor.BLUE;
|
||||
if (world.getEnvironment() == Environment.NETHER) {
|
||||
color = ChatColor.RED;
|
||||
} else if (world.getEnvironment() == Environment.NORMAL) {
|
||||
color = ChatColor.GREEN;
|
||||
} else if (world.getEnvironment() == Environment.SKYLANDS) {
|
||||
color = ChatColor.AQUA;
|
||||
}
|
||||
List<Player> players = world.getPlayers();
|
||||
|
||||
|
||||
String result = "";
|
||||
if (players.size() <= 0) {
|
||||
result = "Empty";
|
||||
@ -68,6 +70,6 @@ public class WhoCommand extends BaseCommand {
|
||||
sender.sendMessage(color + world.getName() + ChatColor.WHITE + " - " + result);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,27 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVCommandHandler;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
|
||||
public class MVSpawn extends MVCommandHandler {
|
||||
|
||||
public MVSpawn(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean perform(CommandSender sender, String[] args) {
|
||||
// TODO: Permissions
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
p.teleport(p.getWorld().getSpawnLocation());
|
||||
} else {
|
||||
sender.sendMessage("Must be used in game.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user