mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-03 22:16:34 +00:00
Re-added many HuskHomes commands
This commit is contained in:
1 parent
d20baa41d1
commit
1b8254d46a
34 files changed
+1485
-47
No files matched your search
@@ -0,0 +1,28 @@
|
||||
package me.william278.huskhomes2.Commands;
|
||||
|
||||
import me.william278.huskhomes2.Objects.TeleportationPoint;
|
||||
import me.william278.huskhomes2.dataManager;
|
||||
import me.william278.huskhomes2.messageManager;
|
||||
import me.william278.huskhomes2.teleportManager;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class backCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
TeleportationPoint lastPosition = dataManager.getPlayerLastPosition(p);
|
||||
if (lastPosition != null) {
|
||||
teleportManager.queueTimedTeleport(p, lastPosition);
|
||||
} else {
|
||||
messageManager.sendMessage(p, "error_no_last_position");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package me.william278.huskhomes2.Commands;
|
||||
|
||||
import me.william278.huskhomes2.messageManager;
|
||||
import me.william278.huskhomes2.settingHandler;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class delWarpCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
if (args.length == 1) {
|
||||
String warpName = args[0];
|
||||
settingHandler.deleteWarp(p, warpName);
|
||||
} else {
|
||||
messageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package me.william278.huskhomes2.Commands;
|
||||
|
||||
import me.william278.huskhomes2.Objects.Home;
|
||||
import me.william278.huskhomes2.dataManager;
|
||||
import me.william278.huskhomes2.editingHandler;
|
||||
import me.william278.huskhomes2.messageManager;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class editHomeCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
if (args.length >= 1) {
|
||||
String homeName = args[0];
|
||||
if (dataManager.homeExists(p.getName(), homeName)) {
|
||||
if (args.length >= 2) {
|
||||
switch (args[1]) {
|
||||
case "location":
|
||||
dataManager.updateHomeLocation(p.getName(), homeName, p.getLocation());
|
||||
messageManager.sendMessage(p, "edit_home_update_location", homeName);
|
||||
return true;
|
||||
case "description":
|
||||
if (args.length >= 3) {
|
||||
// Get the new description
|
||||
StringBuilder newDescription = new StringBuilder();
|
||||
for (int i = 2; i < args.length; i++) {
|
||||
if (i > 2) {
|
||||
newDescription.append(" ").append(args[i]);
|
||||
} else {
|
||||
newDescription = new StringBuilder(args[i]);
|
||||
}
|
||||
}
|
||||
String newDescriptionString = newDescription.toString();
|
||||
|
||||
// Check the description is valid
|
||||
if (!newDescriptionString.matches("[a-zA-Z0-9\\d\\-_\\s]+")) {
|
||||
messageManager.sendMessage(p, "error_edit_home_invalid_description");
|
||||
return true;
|
||||
}
|
||||
|
||||
// Update description
|
||||
dataManager.updateHomeDescription(p.getName(), homeName, newDescriptionString);
|
||||
|
||||
// Confirmation message
|
||||
messageManager.sendMessage(p, "edit_home_update_description", homeName, newDescriptionString);
|
||||
} else {
|
||||
messageManager.sendMessage(p, "error_invalid_syntax", "/edithome <home> description <new description>");
|
||||
}
|
||||
return true;
|
||||
case "rename":
|
||||
if (args.length >= 3) {
|
||||
String newName = args[2];
|
||||
if (newName.length() > 16) {
|
||||
messageManager.sendMessage(p, "error_set_home_invalid_length");
|
||||
return true;
|
||||
}
|
||||
if (!newName.matches("[A-Za-z0-9_\\-]+")) {
|
||||
messageManager.sendMessage(p, "error_set_home_invalid_characters");
|
||||
return true;
|
||||
}
|
||||
if (dataManager.homeExists(p.getName(), newName)) {
|
||||
messageManager.sendMessage(p, "error_set_home_name_taken");
|
||||
return true;
|
||||
}
|
||||
dataManager.updateHomeName(p.getName(), homeName, newName);
|
||||
messageManager.sendMessage(p, "edit_home_update_name", homeName, newName);
|
||||
} else {
|
||||
messageManager.sendMessage(p, "error_invalid_syntax", "/edithome <home> rename <new name>");
|
||||
}
|
||||
return true;
|
||||
case "public":
|
||||
if (!dataManager.getHome(p.getName(), homeName).isPublic()) {
|
||||
dataManager.updateHomePrivacy(p.getName(), homeName, true);
|
||||
messageManager.sendMessage(p, "edit_home_privacy_public_success", homeName);
|
||||
} else {
|
||||
messageManager.sendMessage(p, "error_edit_home_privacy_already_public", homeName);
|
||||
}
|
||||
return true;
|
||||
case "private":
|
||||
if (dataManager.getHome(p.getName(), homeName).isPublic()) {
|
||||
dataManager.updateHomePrivacy(p.getName(), homeName, false);
|
||||
messageManager.sendMessage(p, "edit_home_privacy_private_success", homeName);
|
||||
} else {
|
||||
messageManager.sendMessage(p, "error_edit_home_privacy_already_private", homeName);
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
messageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
Home home = dataManager.getHome(p.getName(), homeName);
|
||||
editingHandler.showEditHomeOptions(p, home);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(p, "error_home_invalid", homeName);
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package me.william278.huskhomes2.Commands;
|
||||
|
||||
import me.william278.huskhomes2.Objects.Home;
|
||||
import me.william278.huskhomes2.Objects.Warp;
|
||||
import me.william278.huskhomes2.dataManager;
|
||||
import me.william278.huskhomes2.editingHandler;
|
||||
import me.william278.huskhomes2.messageManager;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class editWarpCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
if (args.length >= 1) {
|
||||
String warpName = args[0];
|
||||
if (dataManager.warpExists(warpName)) {
|
||||
if (args.length >= 2) {
|
||||
switch (args[1]) {
|
||||
case "location":
|
||||
dataManager.updateWarpLocation(warpName, p.getLocation());
|
||||
messageManager.sendMessage(p, "edit_warp_update_location", warpName);
|
||||
return true;
|
||||
case "description":
|
||||
if (args.length >= 3) {
|
||||
// Get the new description
|
||||
StringBuilder newDescription = new StringBuilder();
|
||||
for (int i = 2; i < args.length; i++) {
|
||||
if (i > 2) {
|
||||
newDescription.append(" ").append(args[i]);
|
||||
} else {
|
||||
newDescription = new StringBuilder(args[i]);
|
||||
}
|
||||
}
|
||||
String newDescriptionString = newDescription.toString();
|
||||
|
||||
// Check the description is valid
|
||||
if (!newDescriptionString.matches("[a-zA-Z0-9\\d\\-_\\s]+")) {
|
||||
messageManager.sendMessage(p, "error_edit_warp_invalid_description");
|
||||
return true;
|
||||
}
|
||||
|
||||
// Update description
|
||||
dataManager.updateWarpDescription(warpName, newDescriptionString);
|
||||
|
||||
// Confirmation message
|
||||
messageManager.sendMessage(p, "edit_warp_update_description", warpName, newDescriptionString);
|
||||
} else {
|
||||
messageManager.sendMessage(p, "error_invalid_syntax", "/editwarp <warp> description <new description>");
|
||||
}
|
||||
return true;
|
||||
case "rename":
|
||||
if (args.length >= 3) {
|
||||
String newName = args[2];
|
||||
if (newName.length() > 16) {
|
||||
messageManager.sendMessage(p, "error_set_warp_invalid_length");
|
||||
return true;
|
||||
}
|
||||
if (!newName.matches("[A-Za-z0-9_\\-]+")) {
|
||||
messageManager.sendMessage(p, "error_set_warp_invalid_characters");
|
||||
return true;
|
||||
}
|
||||
if (dataManager.warpExists(newName)) {
|
||||
messageManager.sendMessage(p, "error_set_warp_name_taken");
|
||||
return true;
|
||||
}
|
||||
dataManager.updateWarpName(warpName, newName);
|
||||
messageManager.sendMessage(p, "edit_warp_update_name", warpName, newName);
|
||||
} else {
|
||||
messageManager.sendMessage(p, "error_invalid_syntax", "/editwarp <warp> rename <new warp>");
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
messageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
Warp warp = dataManager.getWarp(warpName);
|
||||
editingHandler.showEditWarpOptions(p, warp);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(p, "error_warp_invalid", warpName);
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -19,10 +19,10 @@ public class homeCommand implements CommandExecutor {
|
||||
Home home = dataManager.getHome(p.getName(), homeName);
|
||||
teleportManager.queueTimedTeleport(p, home);
|
||||
} else {
|
||||
messageManager.sendMessage(p, "error_home_invalid");
|
||||
messageManager.sendMessage(p, "error_home_invalid", homeName);
|
||||
}
|
||||
} else {
|
||||
homeListHandler.displayPlayerHomeList(p, 1);
|
||||
listHandler.displayPlayerHomeList(p, 1);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package me.william278.huskhomes2.Commands;
|
||||
|
||||
import me.william278.huskhomes2.homeListHandler;
|
||||
import me.william278.huskhomes2.listHandler;
|
||||
import me.william278.huskhomes2.messageManager;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@@ -22,7 +22,7 @@ public class homeListCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
homeListHandler.displayPlayerHomeList(p, pageNo);
|
||||
listHandler.displayPlayerHomeList(p, pageNo);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
package me.william278.huskhomes2.Commands;
|
||||
|
||||
import me.william278.huskhomes2.Main;
|
||||
import me.william278.huskhomes2.configManager;
|
||||
import me.william278.huskhomes2.messageManager;
|
||||
import me.william278.huskhomes2.versionChecker;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import static net.md_5.bungee.api.chat.ClickEvent.Action.OPEN_URL;
|
||||
|
||||
public class huskHomesCommand implements CommandExecutor {
|
||||
|
||||
private static final Main plugin = Main.getInstance();
|
||||
|
||||
private static void showAboutMenu(CommandSender sender) {
|
||||
sender.sendMessage(ChatColor.GREEN + "" + ChatColor.BOLD + "HuskHomes" + ChatColor.RESET + " " + ChatColor.GREEN + "| Version " + plugin.getDescription().getVersion());
|
||||
sender.sendMessage(ChatColor.GRAY + plugin.getDescription().getDescription());
|
||||
sender.sendMessage("• Author: " + ChatColor.GRAY + "William278");
|
||||
sender.sendMessage("• Help Wiki: " + ChatColor.GRAY + "https://github.com/WiIIiam278/HuskHomes2/wiki/");
|
||||
sender.sendMessage("• Report a bug: " + ChatColor.GRAY + "https://github.com/WiIIiam278/HuskHomes2/issues");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (args.length >= 1) {
|
||||
switch (args[0]) {
|
||||
case "about":
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
if (!p.hasPermission("huskhomes.about")) {
|
||||
messageManager.sendMessage(p, "error_no_permission");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
showAboutMenu(sender);
|
||||
return true;
|
||||
case "update":
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
if (p.hasPermission("huskhomes.version_checker")) {
|
||||
if (!versionChecker.getVersionCheckString().contains("HuskHomes is up to date!")) {
|
||||
p.sendMessage(org.bukkit.ChatColor.DARK_RED + "Update: " + org.bukkit.ChatColor.RED + versionChecker.getVersionCheckString());
|
||||
|
||||
// Send a link to Spigot downloads page
|
||||
ComponentBuilder componentBuilder = new ComponentBuilder();
|
||||
TextComponent projectURL = new TextComponent("[Download]");
|
||||
ClickEvent clickEvent = new ClickEvent(OPEN_URL, "https://www.spigotmc.org/resources/huskhomes.83767/updates");
|
||||
projectURL.setClickEvent(clickEvent);
|
||||
projectURL.setColor(net.md_5.bungee.api.ChatColor.AQUA);
|
||||
componentBuilder = componentBuilder.append(TextComponent.fromLegacyText("§7Get the latest version: "));
|
||||
componentBuilder = componentBuilder.append(projectURL);
|
||||
p.spigot().sendMessage(componentBuilder.create());
|
||||
} else {
|
||||
p.sendMessage(ChatColor.GREEN + "" + ChatColor.BOLD + "HuskHomes" + ChatColor.RESET + "" + ChatColor.GREEN + " | HuskHomes is up-to-date! (Version " + plugin.getDescription().getVersion() + ")");
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(p, "error_no_permission");
|
||||
}
|
||||
} else {
|
||||
plugin.getLogger().info(versionChecker.getVersionCheckString());
|
||||
}
|
||||
return true;
|
||||
case "reload":
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
if (p.hasPermission("huskhomes.reload")) {
|
||||
configManager.loadConfig();
|
||||
messageManager.loadMessages(Main.settings.getLanguage());
|
||||
p.sendMessage(ChatColor.GREEN + "" + ChatColor.BOLD + "HuskHomes" + ChatColor.RESET + "" + ChatColor.GREEN + " | Reloaded config and message files.");
|
||||
} else {
|
||||
messageManager.sendMessage(p, "error_no_permission");
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
configManager.loadConfig();
|
||||
messageManager.loadMessages(Main.settings.getLanguage());
|
||||
plugin.getLogger().info("Reloaded config and message files.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
if (!p.hasPermission("huskhomes.about")) {
|
||||
messageManager.sendMessage(p, "error_no_permission");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
showAboutMenu(sender);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package me.william278.huskhomes2.Commands;
|
||||
|
||||
import me.william278.huskhomes2.Objects.Home;
|
||||
import me.william278.huskhomes2.dataManager;
|
||||
import me.william278.huskhomes2.listHandler;
|
||||
import me.william278.huskhomes2.messageManager;
|
||||
import me.william278.huskhomes2.teleportManager;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class publicHomeCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
if (args.length == 1) {
|
||||
String publicHome = args[0];
|
||||
if (publicHome.matches("^(?!.*\\..*\\..*)[A-Za-z0-9_\\-]([A-Za-z0-9_\\-.]*[A-Za-z0-9_\\-])?$")) {
|
||||
String ownerName = publicHome.split("\\.")[0];
|
||||
String homeName = publicHome.split("\\.")[1];
|
||||
if (dataManager.homeExists(ownerName, homeName)) {
|
||||
Home home = dataManager.getHome(ownerName, homeName);
|
||||
if (home.isPublic()) {
|
||||
teleportManager.queueTimedTeleport(p, home);
|
||||
} else {
|
||||
messageManager.sendMessage(p, "error_public_home_invalid", ownerName, homeName);
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(p, "error_public_home_invalid", ownerName, homeName);
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||
}
|
||||
} else {
|
||||
listHandler.displayPublicHomeList(p, 1);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package me.william278.huskhomes2.Commands;
|
||||
|
||||
import me.william278.huskhomes2.listHandler;
|
||||
import me.william278.huskhomes2.messageManager;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class publicHomeListCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
int pageNo = 1;
|
||||
if (args.length == 1) {
|
||||
try {
|
||||
pageNo = Integer.parseInt(args[0]);
|
||||
} catch (Exception e) {
|
||||
messageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
listHandler.displayPublicHomeList(p, pageNo);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package me.william278.huskhomes2.Commands;
|
||||
|
||||
import me.william278.huskhomes2.messageManager;
|
||||
import me.william278.huskhomes2.settingHandler;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class setWarpCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
if (args.length == 1) {
|
||||
String warpName = args[0];
|
||||
settingHandler.setWarp(p.getLocation(), p, warpName);
|
||||
} else {
|
||||
messageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package me.william278.huskhomes2.Commands;
|
||||
|
||||
import me.william278.huskhomes2.teleportRequestHandler;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class tpAcceptCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
teleportRequestHandler.replyTpRequest(p, true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package me.william278.huskhomes2.Commands;
|
||||
|
||||
import me.william278.huskhomes2.Main;
|
||||
import me.william278.huskhomes2.Objects.TeleportationPoint;
|
||||
import me.william278.huskhomes2.messageManager;
|
||||
import me.william278.huskhomes2.teleportManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class tpCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
if (args.length >= 1) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
String targetPlayer = args[0];
|
||||
teleportManager.teleportPlayer(p, targetPlayer);
|
||||
return true;
|
||||
case 3:
|
||||
try {
|
||||
double x = Double.parseDouble(args[0]);
|
||||
double y = Double.parseDouble(args[1]);
|
||||
double z = Double.parseDouble(args[2]);
|
||||
TeleportationPoint teleportationPoint = new TeleportationPoint(p.getWorld().getName(), x, y, z, 0F, 0F, Main.settings.getServerID());
|
||||
teleportManager.teleportPlayer(p, teleportationPoint);
|
||||
} catch (Exception e) {
|
||||
messageManager.sendMessage(p, "error_invalid_syntax", "/tp <x> <y> <z>");
|
||||
}
|
||||
return true;
|
||||
case 4:
|
||||
try {
|
||||
double x = Double.parseDouble(args[0]);
|
||||
double y = Double.parseDouble(args[1]);
|
||||
double z = Double.parseDouble(args[2]);
|
||||
String worldName = args[3];
|
||||
if (Bukkit.getWorld(worldName) == null) {
|
||||
messageManager.sendMessage(p, "error_invalid_syntax", "/tp <x> <y> <z> <world>");
|
||||
return true;
|
||||
}
|
||||
TeleportationPoint teleportationPoint = new TeleportationPoint(worldName, x, y, z, 0F, 0F, Main.settings.getServerID());
|
||||
teleportManager.teleportPlayer(p, teleportationPoint);
|
||||
} catch (Exception e) {
|
||||
messageManager.sendMessage(p, "error_invalid_syntax", "/tp <x> <y> <z> <world>");
|
||||
}
|
||||
return true;
|
||||
case 5:
|
||||
if (Main.settings.doBungee()) {
|
||||
try {
|
||||
double x = Double.parseDouble(args[0]);
|
||||
double y = Double.parseDouble(args[1]);
|
||||
double z = Double.parseDouble(args[2]);
|
||||
String worldName = args[3];
|
||||
String serverName = args[4];
|
||||
if (Bukkit.getWorld(worldName) == null) {
|
||||
messageManager.sendMessage(p, "error_invalid_syntax", "/tp <x> <y> <z> <world> <server>");
|
||||
return true;
|
||||
}
|
||||
TeleportationPoint teleportationPoint = new TeleportationPoint(worldName, x, y, z, 0F, 0F, serverName);
|
||||
teleportManager.teleportPlayer(p, teleportationPoint);
|
||||
} catch (Exception e) {
|
||||
messageManager.sendMessage(p, "error_invalid_syntax", "/tp <x> <y> <z> <world> <server>");
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package me.william278.huskhomes2.Commands;
|
||||
|
||||
import me.william278.huskhomes2.teleportRequestHandler;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class tpDenyCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
teleportRequestHandler.replyTpRequest(p, false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package me.william278.huskhomes2.Commands;
|
||||
|
||||
import me.william278.huskhomes2.messageManager;
|
||||
import me.william278.huskhomes2.teleportManager;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class tpHereCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
if (args.length == 1) {
|
||||
String targetPlayer = args[0];
|
||||
teleportManager.teleportPlayer(p, targetPlayer);
|
||||
} else {
|
||||
messageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package me.william278.huskhomes2.Commands;
|
||||
|
||||
import me.william278.huskhomes2.messageManager;
|
||||
import me.william278.huskhomes2.teleportRequestHandler;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class tpaCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
if (args.length == 1) {
|
||||
String targetPlayer = args[0];
|
||||
teleportRequestHandler.sendTeleportToRequest(p, targetPlayer);
|
||||
} else {
|
||||
messageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package me.william278.huskhomes2.Commands;
|
||||
|
||||
import me.william278.huskhomes2.messageManager;
|
||||
import me.william278.huskhomes2.teleportManager;
|
||||
import me.william278.huskhomes2.teleportRequestHandler;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class tpaHereCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
if (args.length == 1) {
|
||||
String targetPlayer = args[0];
|
||||
teleportRequestHandler.sendTeleportHereRequest(p, targetPlayer);
|
||||
} else {
|
||||
messageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package me.william278.huskhomes2.Commands;
|
||||
|
||||
import me.william278.huskhomes2.Objects.Warp;
|
||||
import me.william278.huskhomes2.dataManager;
|
||||
import me.william278.huskhomes2.listHandler;
|
||||
import me.william278.huskhomes2.messageManager;
|
||||
import me.william278.huskhomes2.teleportManager;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class warpCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
if (args.length == 1) {
|
||||
String warpName = args[0];
|
||||
if (dataManager.warpExists(warpName)) {
|
||||
Warp warp = dataManager.getWarp(warpName);
|
||||
teleportManager.queueTimedTeleport(p, warp);
|
||||
} else {
|
||||
messageManager.sendMessage(p, "error_warp_invalid", warpName);
|
||||
}
|
||||
} else {
|
||||
listHandler.displayWarpList(p, 1);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package me.william278.huskhomes2.Commands;
|
||||
|
||||
import me.william278.huskhomes2.listHandler;
|
||||
import me.william278.huskhomes2.messageManager;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class warpListCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
int pageNo = 1;
|
||||
if (args.length == 1) {
|
||||
try {
|
||||
pageNo = Integer.parseInt(args[0]);
|
||||
} catch (Exception e) {
|
||||
messageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
listHandler.displayWarpList(p, pageNo);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user