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.database.commands.MmoupdateCommand;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.party.commands.PartyCommand;
|
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.acrobatics.AcrobaticsCommand;
|
||||||
import com.gmail.nossr50.skills.archery.ArcheryCommand;
|
import com.gmail.nossr50.skills.archery.ArcheryCommand;
|
||||||
import com.gmail.nossr50.skills.axes.AxesCommand;
|
import com.gmail.nossr50.skills.axes.AxesCommand;
|
||||||
@ -324,4 +325,14 @@ public final class CommandRegistrationHelper {
|
|||||||
command.setPermissionMessage(permissionsMessage);
|
command.setPermissionMessage(permissionsMessage);
|
||||||
command.setExecutor(new PartyCommand());
|
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.registerAdminChatCommand();
|
||||||
CommandRegistrationHelper.registerPartyCommand();
|
CommandRegistrationHelper.registerPartyCommand();
|
||||||
CommandRegistrationHelper.registerPartyChatCommand();
|
CommandRegistrationHelper.registerPartyChatCommand();
|
||||||
getCommand("ptp").setExecutor(new PtpCommand());
|
CommandRegistrationHelper.registerPtpCommand();
|
||||||
|
|
||||||
// Other commands
|
// Other commands
|
||||||
CommandRegistrationHelper.registerAddxpCommand();
|
CommandRegistrationHelper.registerAddxpCommand();
|
||||||
|
@ -23,16 +23,10 @@ public class PtpCommand implements CommandExecutor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
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)) {
|
if (CommandHelper.noConsoleUsage(sender)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.ptp")) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1:
|
case 1:
|
||||||
player = (Player) sender;
|
player = (Player) sender;
|
||||||
@ -42,7 +36,8 @@ public class PtpCommand implements CommandExecutor {
|
|||||||
if (args[0].equalsIgnoreCase("toggle")) {
|
if (args[0].equalsIgnoreCase("toggle")) {
|
||||||
return togglePartyTeleportation();
|
return togglePartyTeleportation();
|
||||||
}
|
}
|
||||||
else if (args[0].equalsIgnoreCase("acceptany") || args[0].equalsIgnoreCase("acceptall")) {
|
|
||||||
|
if (args[0].equalsIgnoreCase("acceptany") || args[0].equalsIgnoreCase("acceptall")) {
|
||||||
return acceptAnyTeleportRequest();
|
return acceptAnyTeleportRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,24 +55,30 @@ public class PtpCommand implements CommandExecutor {
|
|||||||
return sendTeleportRequest(args[0]);
|
return sendTeleportRequest(args[0]);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
sender.sendMessage(usage);
|
return false;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean sendTeleportRequest(String args) {
|
private boolean sendTeleportRequest(String playerName) {
|
||||||
Player target = mcMMO.p.getServer().getPlayer(args);
|
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)) {
|
if (player.equals(target)) {
|
||||||
player.sendMessage(LocaleLoader.getString("Party.Teleport.Self"));
|
player.sendMessage(LocaleLoader.getString("Party.Teleport.Self"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target == null) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (target.isDead()) {
|
if (target.isDead()) {
|
||||||
player.sendMessage(LocaleLoader.getString("Party.Teleport.Dead"));
|
player.sendMessage(LocaleLoader.getString("Party.Teleport.Dead"));
|
||||||
return true;
|
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.mmoupdate=Convert mcMMO database from Flatfile to MySQL
|
||||||
Commands.Description.party=Control various mcMMO party settings
|
Commands.Description.party=Control various mcMMO party settings
|
||||||
Commands.Description.partychat=Toggle mcMMO party chat on/off or send party chat messages
|
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.Skill=Display detailed mcMMO skill info for {0}
|
||||||
Commands.Description.skillreset=Reset mcMMO levels for a user
|
Commands.Description.skillreset=Reset mcMMO levels for a user
|
||||||
Commands.Description.xplock=Lock your mcMMO XP bar to a specific mcMMO skill
|
Commands.Description.xplock=Lock your mcMMO XP bar to a specific mcMMO skill
|
||||||
|
Loading…
Reference in New Issue
Block a user