mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-27 00:45:40 +01:00
Added /mmocore waypoints teleport
This commit is contained in:
parent
ee41d3bf38
commit
ca7c90f7c1
@ -0,0 +1,43 @@
|
|||||||
|
package net.Indyuce.mmocore.command.rpg.waypoint;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
|
import net.Indyuce.mmocore.api.Waypoint;
|
||||||
|
import net.mmogroup.mmolib.command.api.CommandTreeNode;
|
||||||
|
import net.mmogroup.mmolib.command.api.Parameter;
|
||||||
|
|
||||||
|
public class TeleportCommandTreeNode extends CommandTreeNode {
|
||||||
|
public TeleportCommandTreeNode(CommandTreeNode parent) {
|
||||||
|
super(parent, "teleport");
|
||||||
|
|
||||||
|
addParameter(new Parameter("<waypoint>", (explorer, list) -> MMOCore.plugin.waypointManager.getAll().forEach(way -> list.add(way.getId()))));
|
||||||
|
addParameter(Parameter.PLAYER);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommandResult execute(CommandSender sender, String[] args) {
|
||||||
|
if (args.length < 4)
|
||||||
|
return CommandResult.THROW_USAGE;
|
||||||
|
|
||||||
|
if (!MMOCore.plugin.waypointManager.has(args[2])) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "Could not find waypoint " + args[2]);
|
||||||
|
return CommandResult.FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = Bukkit.getPlayer(args[3]);
|
||||||
|
if (player == null) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "Could not find player " + args[3]);
|
||||||
|
return CommandResult.FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
Waypoint waypoint = MMOCore.plugin.waypointManager.get(args[2]);
|
||||||
|
player.teleport(waypoint.getLocation());
|
||||||
|
sender.sendMessage(ChatColor.YELLOW + "Successfully teleported " + ChatColor.GOLD + player.getName() + ChatColor.YELLOW + " to "
|
||||||
|
+ ChatColor.GOLD + waypoint.getId() + ChatColor.YELLOW + ".");
|
||||||
|
return CommandResult.SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
@ -10,6 +10,7 @@ public class WaypointsCommandTreeNode extends CommandTreeNode {
|
|||||||
|
|
||||||
addChild(new UnlockCommandTreeNode(this));
|
addChild(new UnlockCommandTreeNode(this));
|
||||||
addChild(new OpenCommandTreeNode(this));
|
addChild(new OpenCommandTreeNode(this));
|
||||||
|
addChild(new TeleportCommandTreeNode(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user