mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 21:26:46 +01:00
Convert /ptp to use Bukkit CommandAPI
This commit is contained in:
parent
92473cc56d
commit
adda85a660
@ -27,6 +27,7 @@ import com.gmail.nossr50.database.commands.McremoveCommand;
|
||||
import com.gmail.nossr50.database.commands.MmoupdateCommand;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.commands.PartyCommand;
|
||||
import com.gmail.nossr50.party.commands.PtpCommand;
|
||||
import com.gmail.nossr50.skills.acrobatics.AcrobaticsCommand;
|
||||
import com.gmail.nossr50.skills.archery.ArcheryCommand;
|
||||
import com.gmail.nossr50.skills.axes.AxesCommand;
|
||||
@ -324,4 +325,14 @@ public final class CommandRegistrationHelper {
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setExecutor(new PartyCommand());
|
||||
}
|
||||
|
||||
public static void registerPtpCommand() {
|
||||
PluginCommand command = mcMMO.p.getCommand("ptp");
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.ptp"));
|
||||
command.setPermission("mcmmo.commands.ptp;mcmmo.commands.ptp.accept;mcmmo.commands.ptp.acceptall;mcmmo.commands.ptp.toggle");
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "ptp", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
|
||||
command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "ptp", "<toggle|accept|acceptall>"));
|
||||
command.setExecutor(new PtpCommand());
|
||||
}
|
||||
}
|
||||
|
@ -290,7 +290,7 @@ public class mcMMO extends JavaPlugin {
|
||||
CommandRegistrationHelper.registerAdminChatCommand();
|
||||
CommandRegistrationHelper.registerPartyCommand();
|
||||
CommandRegistrationHelper.registerPartyChatCommand();
|
||||
getCommand("ptp").setExecutor(new PtpCommand());
|
||||
CommandRegistrationHelper.registerPtpCommand();
|
||||
|
||||
// Other commands
|
||||
CommandRegistrationHelper.registerAddxpCommand();
|
||||
|
@ -23,16 +23,10 @@ public class PtpCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
String usage = LocaleLoader.getString("Commands.Usage.1", "ptp", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">");
|
||||
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.ptp")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
player = (Player) sender;
|
||||
@ -42,7 +36,8 @@ public class PtpCommand implements CommandExecutor {
|
||||
if (args[0].equalsIgnoreCase("toggle")) {
|
||||
return togglePartyTeleportation();
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("acceptany") || args[0].equalsIgnoreCase("acceptall")) {
|
||||
|
||||
if (args[0].equalsIgnoreCase("acceptany") || args[0].equalsIgnoreCase("acceptall")) {
|
||||
return acceptAnyTeleportRequest();
|
||||
}
|
||||
|
||||
@ -60,24 +55,30 @@ public class PtpCommand implements CommandExecutor {
|
||||
return sendTeleportRequest(args[0]);
|
||||
|
||||
default:
|
||||
sender.sendMessage(usage);
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean sendTeleportRequest(String args) {
|
||||
Player target = mcMMO.p.getServer().getPlayer(args);
|
||||
private boolean sendTeleportRequest(String playerName) {
|
||||
if (!mcMMO.p.getServer().getOfflinePlayer(playerName).isOnline()) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.NotOnline", playerName));
|
||||
return true;
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOTarget = Users.getPlayer(playerName);
|
||||
|
||||
if (mcMMOTarget == null) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
Player target = mcMMOTarget.getPlayer();
|
||||
|
||||
if (player.equals(target)) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Teleport.Self"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (target == null) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (target.isDead()) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Teleport.Dead"));
|
||||
return true;
|
||||
|
@ -709,6 +709,7 @@ Commands.Description.mmoedit=Edit mcMMO levels for a user
|
||||
Commands.Description.mmoupdate=Convert mcMMO database from Flatfile to MySQL
|
||||
Commands.Description.party=Control various mcMMO party settings
|
||||
Commands.Description.partychat=Toggle mcMMO party chat on/off or send party chat messages
|
||||
Commands.Description.ptp=Teleport to an mcMMO party member
|
||||
Commands.Description.Skill=Display detailed mcMMO skill info for {0}
|
||||
Commands.Description.skillreset=Reset mcMMO levels for a user
|
||||
Commands.Description.xplock=Lock your mcMMO XP bar to a specific mcMMO skill
|
||||
|
Loading…
Reference in New Issue
Block a user