mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-04 14:38:53 +00:00
Let's use some more of CommandBase
This commit is contained in:
29 files changed
+541
-643
No files matched your search
@@ -5,23 +5,18 @@ import me.william278.huskhomes2.data.DataManager;
|
|||||||
import me.william278.huskhomes2.teleport.TeleportManager;
|
import me.william278.huskhomes2.teleport.TeleportManager;
|
||||||
import me.william278.huskhomes2.teleport.points.TeleportationPoint;
|
import me.william278.huskhomes2.teleport.points.TeleportationPoint;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class BackCommand extends CommandBase {
|
public class BackCommand extends CommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||||
if (sender instanceof Player) {
|
TeleportationPoint lastPosition = DataManager.getPlayerLastPosition(p);
|
||||||
Player p = (Player) sender;
|
if (lastPosition != null) {
|
||||||
TeleportationPoint lastPosition = DataManager.getPlayerLastPosition(p);
|
TeleportManager.queueTimedTeleport(p, lastPosition);
|
||||||
if (lastPosition != null) {
|
} else {
|
||||||
TeleportManager.queueTimedTeleport(p, lastPosition);
|
MessageManager.sendMessage(p, "error_no_last_position");
|
||||||
} else {
|
|
||||||
MessageManager.sendMessage(p, "error_no_last_position");
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,12 +5,23 @@ import org.bukkit.command.CommandExecutor;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.PluginCommand;
|
import org.bukkit.command.PluginCommand;
|
||||||
import org.bukkit.command.TabCompleter;
|
import org.bukkit.command.TabCompleter;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public abstract class CommandBase implements CommandExecutor {
|
public abstract class CommandBase implements CommandExecutor {
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if (sender instanceof Player) {
|
||||||
|
return onCommand((Player) sender, command, label, args);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract boolean onCommand(Player player, Command command, String label, String[] args);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register base for bukkit command
|
* Register base for bukkit command
|
||||||
* @param command Command for registration
|
* @param command Command for registration
|
||||||
|
|||||||
@@ -3,24 +3,19 @@ package me.william278.huskhomes2.commands;
|
|||||||
import me.william278.huskhomes2.MessageManager;
|
import me.william278.huskhomes2.MessageManager;
|
||||||
import me.william278.huskhomes2.teleport.SettingHandler;
|
import me.william278.huskhomes2.teleport.SettingHandler;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class DelhomeCommand extends CommandBase {
|
public class DelhomeCommand extends CommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||||
if (sender instanceof Player) {
|
if (args.length == 1) {
|
||||||
Player p = (Player) sender;
|
String homeName = args[0];
|
||||||
if (args.length == 1) {
|
SettingHandler.deleteHome(p, homeName);
|
||||||
String homeName = args[0];
|
} else {
|
||||||
SettingHandler.deleteHome(p, homeName);
|
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||||
} else {
|
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -3,24 +3,19 @@ package me.william278.huskhomes2.commands;
|
|||||||
import me.william278.huskhomes2.MessageManager;
|
import me.william278.huskhomes2.MessageManager;
|
||||||
import me.william278.huskhomes2.teleport.SettingHandler;
|
import me.william278.huskhomes2.teleport.SettingHandler;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class DelwarpCommand extends CommandBase {
|
public class DelwarpCommand extends CommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||||
if (sender instanceof Player) {
|
if (args.length == 1) {
|
||||||
Player p = (Player) sender;
|
String warpName = args[0];
|
||||||
if (args.length == 1) {
|
SettingHandler.deleteWarp(p, warpName);
|
||||||
String warpName = args[0];
|
} else {
|
||||||
SettingHandler.deleteWarp(p, warpName);
|
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||||
} else {
|
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -28,192 +28,188 @@ import java.util.List;
|
|||||||
public class EdithomeCommand extends CommandBase implements TabCompleter {
|
public class EdithomeCommand extends CommandBase implements TabCompleter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||||
if (sender instanceof Player) {
|
if (args.length >= 1) {
|
||||||
Player p = (Player) sender;
|
String homeName = args[0];
|
||||||
if (args.length >= 1) {
|
if (DataManager.homeExists(p.getName(), homeName)) {
|
||||||
String homeName = args[0];
|
if (args.length >= 2) {
|
||||||
if (DataManager.homeExists(p.getName(), homeName)) {
|
switch (args[1]) {
|
||||||
if (args.length >= 2) {
|
case "location":
|
||||||
switch (args[1]) {
|
Location newLocation = p.getLocation();
|
||||||
case "location":
|
TeleportationPoint newTeleportLocation = new TeleportationPoint(newLocation, HuskHomes.settings.getServerID());
|
||||||
Location newLocation = p.getLocation();
|
|
||||||
TeleportationPoint newTeleportLocation = new TeleportationPoint(newLocation, HuskHomes.settings.getServerID());
|
|
||||||
|
|
||||||
// Remove old marker if on dynmap
|
// Remove old marker if on dynmap
|
||||||
Home locationMovedHome = DataManager.getHome(p.getName(), homeName);
|
Home locationMovedHome = DataManager.getHome(p.getName(), homeName);
|
||||||
if (locationMovedHome.isPublic() && HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
if (locationMovedHome.isPublic() && HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
||||||
DynMapIntegration.removeDynamicMapMarker(homeName, p.getName());
|
DynMapIntegration.removeDynamicMapMarker(homeName, p.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayerRelocateHomeEvent relocateHomeEvent = new PlayerRelocateHomeEvent(p, locationMovedHome, newTeleportLocation);
|
||||||
|
Bukkit.getPluginManager().callEvent(relocateHomeEvent);
|
||||||
|
if (relocateHomeEvent.isCancelled()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
DataManager.updateHomeLocation(p.getName(), homeName, newLocation);
|
||||||
|
MessageManager.sendMessage(p, "edit_home_update_location", homeName);
|
||||||
|
|
||||||
|
// Add new updated marker if using dynmap
|
||||||
|
locationMovedHome.setLocation(newLocation, HuskHomes.settings.getServerID());
|
||||||
|
if (locationMovedHome.isPublic() && HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
||||||
|
DynMapIntegration.addDynamicMapMarker(locationMovedHome);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
case "description":
|
||||||
|
if (args.length >= 3) {
|
||||||
|
Home descriptionChangedHome = DataManager.getHome(p.getName(), homeName);
|
||||||
|
|
||||||
|
// 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();
|
||||||
PlayerRelocateHomeEvent relocateHomeEvent = new PlayerRelocateHomeEvent(p, locationMovedHome, newTeleportLocation);
|
PlayerChangeHomeDescriptionEvent changeHomeDescriptionEvent = new PlayerChangeHomeDescriptionEvent(p, descriptionChangedHome, newDescriptionString);
|
||||||
Bukkit.getPluginManager().callEvent(relocateHomeEvent);
|
Bukkit.getPluginManager().callEvent(changeHomeDescriptionEvent);
|
||||||
if (relocateHomeEvent.isCancelled()) {
|
if (changeHomeDescriptionEvent.isCancelled()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// Check the description is valid
|
||||||
|
if (!newDescriptionString.matches("[a-zA-Z0-9\\d\\-_\\s]+") || newDescriptionString.length() > 255) {
|
||||||
|
MessageManager.sendMessage(p, "error_edit_home_invalid_description");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
DataManager.updateHomeLocation(p.getName(), homeName, newLocation);
|
// Remove old marker if on the Dynmap
|
||||||
MessageManager.sendMessage(p, "edit_home_update_location", homeName);
|
if (descriptionChangedHome.isPublic() && HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
||||||
|
DynMapIntegration.removeDynamicMapMarker(homeName, p.getName());
|
||||||
// Add new updated marker if using dynmap
|
|
||||||
locationMovedHome.setLocation(newLocation, HuskHomes.settings.getServerID());
|
|
||||||
if (locationMovedHome.isPublic() && HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
|
||||||
DynMapIntegration.addDynamicMapMarker(locationMovedHome);
|
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
case "description":
|
|
||||||
if (args.length >= 3) {
|
|
||||||
Home descriptionChangedHome = DataManager.getHome(p.getName(), homeName);
|
|
||||||
|
|
||||||
// Get the new description
|
// Update description
|
||||||
StringBuilder newDescription = new StringBuilder();
|
DataManager.updateHomeDescription(p.getName(), homeName, newDescriptionString);
|
||||||
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();
|
|
||||||
PlayerChangeHomeDescriptionEvent changeHomeDescriptionEvent = new PlayerChangeHomeDescriptionEvent(p, descriptionChangedHome, newDescriptionString);
|
|
||||||
Bukkit.getPluginManager().callEvent(changeHomeDescriptionEvent);
|
|
||||||
if (changeHomeDescriptionEvent.isCancelled()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// Check the description is valid
|
|
||||||
if (!newDescriptionString.matches("[a-zA-Z0-9\\d\\-_\\s]+") || newDescriptionString.length() > 255) {
|
|
||||||
MessageManager.sendMessage(p, "error_edit_home_invalid_description");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove old marker if on the Dynmap
|
// Add new marker if using Dynmap
|
||||||
if (descriptionChangedHome.isPublic() && HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
descriptionChangedHome.setDescription(newDescriptionString);
|
||||||
|
if (descriptionChangedHome.isPublic() && HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
||||||
|
DynMapIntegration.addDynamicMapMarker(descriptionChangedHome);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
Home renamedHome = DataManager.getHome(p.getName(), homeName);
|
||||||
|
PlayerRenameHomeEvent renameHomeEvent = new PlayerRenameHomeEvent(p, renamedHome, newName);
|
||||||
|
Bukkit.getPluginManager().callEvent(renameHomeEvent);
|
||||||
|
if (renameHomeEvent.isCancelled()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (renamedHome.isPublic()) {
|
||||||
|
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
||||||
DynMapIntegration.removeDynamicMapMarker(homeName, p.getName());
|
DynMapIntegration.removeDynamicMapMarker(homeName, p.getName());
|
||||||
}
|
}
|
||||||
|
DataManager.updateHomeName(p.getName(), homeName, newName);
|
||||||
// Update description
|
PublichomeCommand.updatePublicHomeTabCache();
|
||||||
DataManager.updateHomeDescription(p.getName(), homeName, newDescriptionString);
|
|
||||||
|
|
||||||
// Add new marker if using Dynmap
|
|
||||||
descriptionChangedHome.setDescription(newDescriptionString);
|
|
||||||
if (descriptionChangedHome.isPublic() && HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
|
||||||
DynMapIntegration.addDynamicMapMarker(descriptionChangedHome);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Confirmation message
|
|
||||||
MessageManager.sendMessage(p, "edit_home_update_description", homeName, newDescriptionString);
|
|
||||||
} else {
|
} else {
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", "/edithome <home> description <new description>");
|
DataManager.updateHomeName(p.getName(), homeName, newName);
|
||||||
}
|
}
|
||||||
return true;
|
renamedHome.setName(newName);
|
||||||
case "rename":
|
if (renamedHome.isPublic() && HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
||||||
if (args.length >= 3) {
|
DynMapIntegration.addDynamicMapMarker(renamedHome);
|
||||||
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;
|
|
||||||
}
|
|
||||||
Home renamedHome = DataManager.getHome(p.getName(), homeName);
|
|
||||||
PlayerRenameHomeEvent renameHomeEvent = new PlayerRenameHomeEvent(p, renamedHome, newName);
|
|
||||||
Bukkit.getPluginManager().callEvent(renameHomeEvent);
|
|
||||||
if (renameHomeEvent.isCancelled()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (renamedHome.isPublic()) {
|
|
||||||
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
|
||||||
DynMapIntegration.removeDynamicMapMarker(homeName, p.getName());
|
|
||||||
}
|
|
||||||
DataManager.updateHomeName(p.getName(), homeName, newName);
|
|
||||||
PublichomeCommand.updatePublicHomeTabCache();
|
|
||||||
} else {
|
|
||||||
DataManager.updateHomeName(p.getName(), homeName, newName);
|
|
||||||
}
|
|
||||||
renamedHome.setName(newName);
|
|
||||||
if (renamedHome.isPublic() && HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
|
||||||
DynMapIntegration.addDynamicMapMarker(renamedHome);
|
|
||||||
}
|
|
||||||
HomeCommand.Tab.updatePlayerHomeCache(p);
|
|
||||||
MessageManager.sendMessage(p, "edit_home_update_name", homeName, newName);
|
|
||||||
} else {
|
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", "/edithome <home> rename <new name>");
|
|
||||||
}
|
}
|
||||||
return true;
|
HomeCommand.Tab.updatePlayerHomeCache(p);
|
||||||
case "public":
|
MessageManager.sendMessage(p, "edit_home_update_name", homeName, newName);
|
||||||
Home privateHome = DataManager.getHome(p.getName(), homeName);
|
} else {
|
||||||
if (!privateHome.isPublic()) {
|
MessageManager.sendMessage(p, "error_invalid_syntax", "/edithome <home> rename <new name>");
|
||||||
if (HuskHomes.settings.doEconomy()) {
|
}
|
||||||
double publicHomeCost = HuskHomes.settings.getPublicHomeCost();
|
return true;
|
||||||
if (publicHomeCost > 0) {
|
case "public":
|
||||||
if (!VaultIntegration.takeMoney(p, publicHomeCost)) {
|
Home privateHome = DataManager.getHome(p.getName(), homeName);
|
||||||
MessageManager.sendMessage(p, "error_insufficient_funds", VaultIntegration.format(publicHomeCost));
|
if (!privateHome.isPublic()) {
|
||||||
return true;
|
if (HuskHomes.settings.doEconomy()) {
|
||||||
} else {
|
double publicHomeCost = HuskHomes.settings.getPublicHomeCost();
|
||||||
MessageManager.sendMessage(p, "edit_home_privacy_public_success_economy", homeName, VaultIntegration.format(publicHomeCost));
|
if (publicHomeCost > 0) {
|
||||||
}
|
if (!VaultIntegration.takeMoney(p, publicHomeCost)) {
|
||||||
|
MessageManager.sendMessage(p, "error_insufficient_funds", VaultIntegration.format(publicHomeCost));
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
MessageManager.sendMessage(p, "edit_home_privacy_public_success", homeName);
|
MessageManager.sendMessage(p, "edit_home_privacy_public_success_economy", homeName, VaultIntegration.format(publicHomeCost));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
MessageManager.sendMessage(p, "edit_home_privacy_public_success", homeName);
|
MessageManager.sendMessage(p, "edit_home_privacy_public_success", homeName);
|
||||||
}
|
}
|
||||||
PlayerMakeHomePublicEvent makeHomePublicEvent = new PlayerMakeHomePublicEvent(p, privateHome);
|
|
||||||
Bukkit.getPluginManager().callEvent(makeHomePublicEvent);
|
|
||||||
if (makeHomePublicEvent.isCancelled()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
DataManager.updateHomePrivacy(p.getName(), homeName, true);
|
|
||||||
PublichomeCommand.updatePublicHomeTabCache();
|
|
||||||
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
|
||||||
DynMapIntegration.addDynamicMapMarker(privateHome);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
MessageManager.sendMessage(p, "error_edit_home_privacy_already_public", homeName);
|
MessageManager.sendMessage(p, "edit_home_privacy_public_success", homeName);
|
||||||
}
|
}
|
||||||
return true;
|
PlayerMakeHomePublicEvent makeHomePublicEvent = new PlayerMakeHomePublicEvent(p, privateHome);
|
||||||
case "private":
|
Bukkit.getPluginManager().callEvent(makeHomePublicEvent);
|
||||||
Home publicHome = DataManager.getHome(p.getName(), homeName);
|
if (makeHomePublicEvent.isCancelled()) {
|
||||||
if (publicHome.isPublic()) {
|
return true;
|
||||||
PlayerMakeHomePrivateEvent makeHomePrivateEvent = new PlayerMakeHomePrivateEvent(p, publicHome);
|
|
||||||
Bukkit.getPluginManager().callEvent(makeHomePrivateEvent);
|
|
||||||
if (makeHomePrivateEvent.isCancelled()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
DataManager.updateHomePrivacy(p.getName(), homeName, false);
|
|
||||||
MessageManager.sendMessage(p, "edit_home_privacy_private_success", homeName);
|
|
||||||
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
|
||||||
DynMapIntegration.removeDynamicMapMarker(publicHome.getName(), publicHome.getOwnerUsername());
|
|
||||||
}
|
|
||||||
PublichomeCommand.updatePublicHomeTabCache();
|
|
||||||
} else {
|
|
||||||
MessageManager.sendMessage(p, "error_edit_home_privacy_already_private", homeName);
|
|
||||||
}
|
}
|
||||||
return true;
|
DataManager.updateHomePrivacy(p.getName(), homeName, true);
|
||||||
default:
|
PublichomeCommand.updatePublicHomeTabCache();
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
||||||
return true;
|
DynMapIntegration.addDynamicMapMarker(privateHome);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Home home = DataManager.getHome(p.getName(), homeName);
|
MessageManager.sendMessage(p, "error_edit_home_privacy_already_public", homeName);
|
||||||
EditingHandler.showEditHomeOptions(p, home);
|
}
|
||||||
return true;
|
return true;
|
||||||
|
case "private":
|
||||||
|
Home publicHome = DataManager.getHome(p.getName(), homeName);
|
||||||
|
if (publicHome.isPublic()) {
|
||||||
|
PlayerMakeHomePrivateEvent makeHomePrivateEvent = new PlayerMakeHomePrivateEvent(p, publicHome);
|
||||||
|
Bukkit.getPluginManager().callEvent(makeHomePrivateEvent);
|
||||||
|
if (makeHomePrivateEvent.isCancelled()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
DataManager.updateHomePrivacy(p.getName(), homeName, false);
|
||||||
|
MessageManager.sendMessage(p, "edit_home_privacy_private_success", homeName);
|
||||||
|
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
||||||
|
DynMapIntegration.removeDynamicMapMarker(publicHome.getName(), publicHome.getOwnerUsername());
|
||||||
|
}
|
||||||
|
PublichomeCommand.updatePublicHomeTabCache();
|
||||||
|
} 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 {
|
} else {
|
||||||
MessageManager.sendMessage(p, "error_home_invalid", homeName);
|
Home home = DataManager.getHome(p.getName(), homeName);
|
||||||
|
EditingHandler.showEditHomeOptions(p, home);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
MessageManager.sendMessage(p, "error_home_invalid", homeName);
|
||||||
}
|
}
|
||||||
return true;
|
} else {
|
||||||
|
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||||
}
|
}
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -25,139 +25,135 @@ import java.util.List;
|
|||||||
public class EditwarpCommand extends CommandBase implements TabCompleter {
|
public class EditwarpCommand extends CommandBase implements TabCompleter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||||
if (sender instanceof Player) {
|
if (args.length >= 1) {
|
||||||
Player p = (Player) sender;
|
String warpName = args[0];
|
||||||
if (args.length >= 1) {
|
if (DataManager.warpExists(warpName)) {
|
||||||
String warpName = args[0];
|
if (args.length >= 2) {
|
||||||
if (DataManager.warpExists(warpName)) {
|
switch (args[1]) {
|
||||||
if (args.length >= 2) {
|
case "location":
|
||||||
switch (args[1]) {
|
Location newLocation = p.getLocation();
|
||||||
case "location":
|
TeleportationPoint newTeleportLocation = new TeleportationPoint(newLocation, HuskHomes.settings.getServerID());
|
||||||
Location newLocation = p.getLocation();
|
|
||||||
TeleportationPoint newTeleportLocation = new TeleportationPoint(newLocation, HuskHomes.settings.getServerID());
|
// Remove old marker if on the Dynmap
|
||||||
|
Warp locationMovedWarp = DataManager.getWarp(warpName);
|
||||||
|
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showWarpsOnDynmap()) {
|
||||||
|
DynMapIntegration.removeDynamicMapMarker(warpName);
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayerRelocateWarpEvent relocateWarpEvent = new PlayerRelocateWarpEvent(p, locationMovedWarp, newTeleportLocation);
|
||||||
|
Bukkit.getPluginManager().callEvent(relocateWarpEvent);
|
||||||
|
if (relocateWarpEvent.isCancelled()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
DataManager.updateWarpLocation(warpName, p.getLocation());
|
||||||
|
MessageManager.sendMessage(p, "edit_warp_update_location", warpName);
|
||||||
|
|
||||||
|
// Add new updated marker if using Dynmap
|
||||||
|
locationMovedWarp.setLocation(newLocation, HuskHomes.settings.getServerID());
|
||||||
|
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showWarpsOnDynmap()) {
|
||||||
|
DynMapIntegration.addDynamicMapMarker(locationMovedWarp);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
case "description":
|
||||||
|
if (args.length >= 3) {
|
||||||
|
Warp descriptionChangedWarp = DataManager.getWarp(warpName);
|
||||||
|
|
||||||
|
// 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();
|
||||||
|
|
||||||
|
PlayerChangeWarpDescriptionEvent changeWarpDescriptionEvent = new PlayerChangeWarpDescriptionEvent(p, descriptionChangedWarp, newDescriptionString);
|
||||||
|
Bukkit.getPluginManager().callEvent(changeWarpDescriptionEvent);
|
||||||
|
if (changeWarpDescriptionEvent.isCancelled()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check the description is valid
|
||||||
|
if (!newDescriptionString.matches("[a-zA-Z0-9\\d\\-_\\s]+") || newDescriptionString.length() > 255) {
|
||||||
|
MessageManager.sendMessage(p, "error_edit_warp_invalid_description");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Remove old marker if on the Dynmap
|
|
||||||
Warp locationMovedWarp = DataManager.getWarp(warpName);
|
|
||||||
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showWarpsOnDynmap()) {
|
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showWarpsOnDynmap()) {
|
||||||
DynMapIntegration.removeDynamicMapMarker(warpName);
|
DynMapIntegration.removeDynamicMapMarker(warpName);
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerRelocateWarpEvent relocateWarpEvent = new PlayerRelocateWarpEvent(p, locationMovedWarp, newTeleportLocation);
|
// Update description
|
||||||
Bukkit.getPluginManager().callEvent(relocateWarpEvent);
|
DataManager.updateWarpDescription(warpName, newDescriptionString);
|
||||||
if (relocateWarpEvent.isCancelled()) {
|
|
||||||
|
descriptionChangedWarp.setDescription(newDescriptionString);
|
||||||
|
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showWarpsOnDynmap()) {
|
||||||
|
DynMapIntegration.addDynamicMapMarker(descriptionChangedWarp);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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) {
|
||||||
|
Warp renamedWarp = DataManager.getWarp(warpName);
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
PlayerRenameWarpEvent renameWarpEvent = new PlayerRenameWarpEvent(p, renamedWarp, newName);
|
||||||
|
Bukkit.getPluginManager().callEvent(renameWarpEvent);
|
||||||
|
if (renameWarpEvent.isCancelled()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
DataManager.updateWarpLocation(warpName, p.getLocation());
|
|
||||||
MessageManager.sendMessage(p, "edit_warp_update_location", warpName);
|
|
||||||
|
|
||||||
// Add new updated marker if using Dynmap
|
|
||||||
locationMovedWarp.setLocation(newLocation, HuskHomes.settings.getServerID());
|
|
||||||
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showWarpsOnDynmap()) {
|
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showWarpsOnDynmap()) {
|
||||||
DynMapIntegration.addDynamicMapMarker(locationMovedWarp);
|
DynMapIntegration.removeDynamicMapMarker(warpName);
|
||||||
}
|
}
|
||||||
return true;
|
DataManager.updateWarpName(warpName, newName);
|
||||||
case "description":
|
|
||||||
if (args.length >= 3) {
|
|
||||||
Warp descriptionChangedWarp = DataManager.getWarp(warpName);
|
|
||||||
|
|
||||||
// Get the new description
|
renamedWarp.setName(newName);
|
||||||
StringBuilder newDescription = new StringBuilder();
|
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showWarpsOnDynmap()) {
|
||||||
for (int i = 2; i < args.length; i++) {
|
DynMapIntegration.addDynamicMapMarker(renamedWarp);
|
||||||
if (i > 2) {
|
|
||||||
newDescription.append(" ").append(args[i]);
|
|
||||||
} else {
|
|
||||||
newDescription = new StringBuilder(args[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
String newDescriptionString = newDescription.toString();
|
|
||||||
|
|
||||||
PlayerChangeWarpDescriptionEvent changeWarpDescriptionEvent = new PlayerChangeWarpDescriptionEvent(p, descriptionChangedWarp, newDescriptionString);
|
|
||||||
Bukkit.getPluginManager().callEvent(changeWarpDescriptionEvent);
|
|
||||||
if (changeWarpDescriptionEvent.isCancelled()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check the description is valid
|
|
||||||
if (!newDescriptionString.matches("[a-zA-Z0-9\\d\\-_\\s]+") || newDescriptionString.length() > 255) {
|
|
||||||
MessageManager.sendMessage(p, "error_edit_warp_invalid_description");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showWarpsOnDynmap()) {
|
|
||||||
DynMapIntegration.removeDynamicMapMarker(warpName);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update description
|
|
||||||
DataManager.updateWarpDescription(warpName, newDescriptionString);
|
|
||||||
|
|
||||||
descriptionChangedWarp.setDescription(newDescriptionString);
|
|
||||||
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showWarpsOnDynmap()) {
|
|
||||||
DynMapIntegration.addDynamicMapMarker(descriptionChangedWarp);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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;
|
WarpCommand.Tab.updateWarpsTabCache();
|
||||||
case "rename":
|
MessageManager.sendMessage(p, "edit_warp_update_name", warpName, newName);
|
||||||
if (args.length >= 3) {
|
} else {
|
||||||
Warp renamedWarp = DataManager.getWarp(warpName);
|
MessageManager.sendMessage(p, "error_invalid_syntax", "/editwarp <warp> rename <new warp>");
|
||||||
String newName = args[2];
|
}
|
||||||
if (newName.length() > 16) {
|
return true;
|
||||||
MessageManager.sendMessage(p, "error_set_warp_invalid_length");
|
default:
|
||||||
return true;
|
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||||
}
|
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;
|
|
||||||
}
|
|
||||||
PlayerRenameWarpEvent renameWarpEvent = new PlayerRenameWarpEvent(p, renamedWarp, newName);
|
|
||||||
Bukkit.getPluginManager().callEvent(renameWarpEvent);
|
|
||||||
if (renameWarpEvent.isCancelled()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showWarpsOnDynmap()) {
|
|
||||||
DynMapIntegration.removeDynamicMapMarker(warpName);
|
|
||||||
}
|
|
||||||
DataManager.updateWarpName(warpName, newName);
|
|
||||||
|
|
||||||
renamedWarp.setName(newName);
|
|
||||||
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showWarpsOnDynmap()) {
|
|
||||||
DynMapIntegration.addDynamicMapMarker(renamedWarp);
|
|
||||||
}
|
|
||||||
WarpCommand.Tab.updateWarpsTabCache();
|
|
||||||
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 {
|
} else {
|
||||||
MessageManager.sendMessage(p, "error_warp_invalid", warpName);
|
Warp warp = DataManager.getWarp(warpName);
|
||||||
|
EditingHandler.showEditWarpOptions(p, warp);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
MessageManager.sendMessage(p, "error_warp_invalid", warpName);
|
||||||
}
|
}
|
||||||
return true;
|
} else {
|
||||||
|
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||||
}
|
}
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -21,31 +21,27 @@ import java.util.UUID;
|
|||||||
public class HomeCommand extends CommandBase {
|
public class HomeCommand extends CommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||||
if (sender instanceof Player) {
|
if (args.length == 1) {
|
||||||
Player p = (Player) sender;
|
String homeName = args[0];
|
||||||
if (args.length == 1) {
|
if (DataManager.homeExists(p, homeName)) {
|
||||||
String homeName = args[0];
|
Home home = DataManager.getHome(p.getName(), homeName);
|
||||||
if (DataManager.homeExists(p, homeName)) {
|
TeleportManager.queueTimedTeleport(p, home);
|
||||||
Home home = DataManager.getHome(p.getName(), homeName);
|
|
||||||
TeleportManager.queueTimedTeleport(p, home);
|
|
||||||
} else {
|
|
||||||
MessageManager.sendMessage(p, "error_home_invalid", homeName);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
List<Home> homes = DataManager.getPlayerHomes(p.getName());
|
MessageManager.sendMessage(p, "error_home_invalid", homeName);
|
||||||
if (homes != null) {
|
|
||||||
if (homes.size() == 1) {
|
|
||||||
// Teleport the player if they only have one home
|
|
||||||
TeleportManager.queueTimedTeleport(p, homes.get(0));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ListHandler.displayPlayerHomeList(p, 1);
|
|
||||||
}
|
}
|
||||||
return true;
|
} else {
|
||||||
|
List<Home> homes = DataManager.getPlayerHomes(p.getName());
|
||||||
|
if (homes != null) {
|
||||||
|
if (homes.size() == 1) {
|
||||||
|
// Teleport the player if they only have one home
|
||||||
|
TeleportManager.queueTimedTeleport(p, homes.get(0));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ListHandler.displayPlayerHomeList(p, 1);
|
||||||
}
|
}
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Tab implements TabCompleter {
|
public static class Tab implements TabCompleter {
|
||||||
|
|||||||
@@ -3,28 +3,23 @@ package me.william278.huskhomes2.commands;
|
|||||||
import me.william278.huskhomes2.MessageManager;
|
import me.william278.huskhomes2.MessageManager;
|
||||||
import me.william278.huskhomes2.teleport.ListHandler;
|
import me.william278.huskhomes2.teleport.ListHandler;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class HomelistCommand extends CommandBase {
|
public class HomelistCommand extends CommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||||
if (sender instanceof Player) {
|
int pageNo = 1;
|
||||||
Player p = (Player) sender;
|
if (args.length == 1) {
|
||||||
int pageNo = 1;
|
try {
|
||||||
if (args.length == 1) {
|
pageNo = Integer.parseInt(args[0]);
|
||||||
try {
|
} catch (Exception e) {
|
||||||
pageNo = Integer.parseInt(args[0]);
|
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||||
} catch (Exception e) {
|
return true;
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ListHandler.displayPlayerHomeList(p, pageNo);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
ListHandler.displayPlayerHomeList(p, pageNo);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -122,6 +122,11 @@ public class HuskhomesCommand extends CommandBase implements TabCompleter {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean onCommand(Player player, Command command, String label, String[] args) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
|
|||||||
@@ -33,33 +33,29 @@ public class PublichomeCommand extends CommandBase implements TabCompleter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||||
if (sender instanceof Player) {
|
if (args.length == 1) {
|
||||||
Player p = (Player) sender;
|
String publicHome = args[0];
|
||||||
if (args.length == 1) {
|
if (publicHome.matches("[A-Za-z0-9_\\-]+\\.[A-Za-z0-9_\\-]+")) {
|
||||||
String publicHome = args[0];
|
String ownerName = publicHome.split("\\.")[0];
|
||||||
if (publicHome.matches("[A-Za-z0-9_\\-]+\\.[A-Za-z0-9_\\-]+")) {
|
String homeName = publicHome.split("\\.")[1];
|
||||||
String ownerName = publicHome.split("\\.")[0];
|
if (DataManager.homeExists(ownerName, homeName)) {
|
||||||
String homeName = publicHome.split("\\.")[1];
|
Home home = DataManager.getHome(ownerName, homeName);
|
||||||
if (DataManager.homeExists(ownerName, homeName)) {
|
if (home.isPublic()) {
|
||||||
Home home = DataManager.getHome(ownerName, homeName);
|
TeleportManager.queueTimedTeleport(p, home);
|
||||||
if (home.isPublic()) {
|
|
||||||
TeleportManager.queueTimedTeleport(p, home);
|
|
||||||
} else {
|
|
||||||
MessageManager.sendMessage(p, "error_public_home_invalid", ownerName, homeName);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
MessageManager.sendMessage(p, "error_public_home_invalid", ownerName, homeName);
|
MessageManager.sendMessage(p, "error_public_home_invalid", ownerName, homeName);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
MessageManager.sendMessage(p, "error_public_home_invalid", ownerName, homeName);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ListHandler.displayPublicHomeList(p, 1);
|
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||||
}
|
}
|
||||||
return true;
|
} else {
|
||||||
|
ListHandler.displayPublicHomeList(p, 1);
|
||||||
}
|
}
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -3,28 +3,23 @@ package me.william278.huskhomes2.commands;
|
|||||||
import me.william278.huskhomes2.MessageManager;
|
import me.william278.huskhomes2.MessageManager;
|
||||||
import me.william278.huskhomes2.teleport.ListHandler;
|
import me.william278.huskhomes2.teleport.ListHandler;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class PublichomelistCommand extends CommandBase {
|
public class PublichomelistCommand extends CommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||||
if (sender instanceof Player) {
|
int pageNo = 1;
|
||||||
Player p = (Player) sender;
|
if (args.length == 1) {
|
||||||
int pageNo = 1;
|
try {
|
||||||
if (args.length == 1) {
|
pageNo = Integer.parseInt(args[0]);
|
||||||
try {
|
} catch (Exception e) {
|
||||||
pageNo = Integer.parseInt(args[0]);
|
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||||
} catch (Exception e) {
|
return true;
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ListHandler.displayPublicHomeList(p, pageNo);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
ListHandler.displayPublicHomeList(p, pageNo);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -5,26 +5,21 @@ import me.william278.huskhomes2.MessageManager;
|
|||||||
import me.william278.huskhomes2.teleport.TeleportManager;
|
import me.william278.huskhomes2.teleport.TeleportManager;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class RtpCommand extends CommandBase {
|
public class RtpCommand extends CommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||||
if (sender instanceof Player) {
|
if (HuskHomes.settings.doRtpCommand()) {
|
||||||
Player p = (Player) sender;
|
if (p.getWorld().getEnvironment() == World.Environment.NORMAL) {
|
||||||
if (HuskHomes.settings.doRtpCommand()) {
|
TeleportManager.queueRandomTeleport(p);
|
||||||
if (p.getWorld().getEnvironment() == World.Environment.NORMAL) {
|
|
||||||
TeleportManager.queueRandomTeleport(p);
|
|
||||||
} else {
|
|
||||||
MessageManager.sendMessage(p, "error_rtp_invalid_dimension");
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
MessageManager.sendMessage(p, "error_command_disabled");
|
MessageManager.sendMessage(p, "error_rtp_invalid_dimension");
|
||||||
}
|
}
|
||||||
return true;
|
} else {
|
||||||
|
MessageManager.sendMessage(p, "error_command_disabled");
|
||||||
}
|
}
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,29 +4,24 @@ import me.william278.huskhomes2.MessageManager;
|
|||||||
import me.william278.huskhomes2.data.DataManager;
|
import me.william278.huskhomes2.data.DataManager;
|
||||||
import me.william278.huskhomes2.teleport.SettingHandler;
|
import me.william278.huskhomes2.teleport.SettingHandler;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class SethomeCommand extends CommandBase {
|
public class SethomeCommand extends CommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||||
if (sender instanceof Player) {
|
if (args.length == 1) {
|
||||||
Player p = (Player) sender;
|
String homeName = args[0];
|
||||||
if (args.length == 1) {
|
SettingHandler.setHome(p.getLocation(), p, homeName);
|
||||||
String homeName = args[0];
|
} else {
|
||||||
SettingHandler.setHome(p.getLocation(), p, homeName);
|
if (DataManager.getPlayerHomes(p.getName()).size() == 0) {
|
||||||
|
// If the player hasn't set a home yet, set one called "home"
|
||||||
|
SettingHandler.setHome(p.getLocation(), p, "home");
|
||||||
} else {
|
} else {
|
||||||
if (DataManager.getPlayerHomes(p.getName()).size() == 0) {
|
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||||
// If the player hasn't set a home yet, set one called "home"
|
|
||||||
SettingHandler.setHome(p.getLocation(), p, "home");
|
|
||||||
} else {
|
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -4,24 +4,19 @@ import me.william278.huskhomes2.HuskHomes;
|
|||||||
import me.william278.huskhomes2.MessageManager;
|
import me.william278.huskhomes2.MessageManager;
|
||||||
import me.william278.huskhomes2.teleport.SettingHandler;
|
import me.william278.huskhomes2.teleport.SettingHandler;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class SetspawnCommand extends CommandBase {
|
public class SetspawnCommand extends CommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||||
if (sender instanceof Player) {
|
if (HuskHomes.settings.doSpawnCommand()) {
|
||||||
Player p = (Player) sender;
|
SettingHandler.setSpawnLocation(p.getLocation());
|
||||||
if (HuskHomes.settings.doSpawnCommand()) {
|
p.getLocation().getWorld().setSpawnLocation(p.getLocation());
|
||||||
SettingHandler.setSpawnLocation(p.getLocation());
|
MessageManager.sendMessage(p, "set_spawn_success");
|
||||||
p.getLocation().getWorld().setSpawnLocation(p.getLocation());
|
} else {
|
||||||
MessageManager.sendMessage(p, "set_spawn_success");
|
MessageManager.sendMessage(p, "error_command_disabled");
|
||||||
} else {
|
|
||||||
MessageManager.sendMessage(p, "error_command_disabled");
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,24 +3,19 @@ package me.william278.huskhomes2.commands;
|
|||||||
import me.william278.huskhomes2.MessageManager;
|
import me.william278.huskhomes2.MessageManager;
|
||||||
import me.william278.huskhomes2.teleport.SettingHandler;
|
import me.william278.huskhomes2.teleport.SettingHandler;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class SetwarpCommand extends CommandBase {
|
public class SetwarpCommand extends CommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||||
if (sender instanceof Player) {
|
if (args.length == 1) {
|
||||||
Player p = (Player) sender;
|
String warpName = args[0];
|
||||||
if (args.length == 1) {
|
SettingHandler.setWarp(p.getLocation(), p, warpName);
|
||||||
String warpName = args[0];
|
} else {
|
||||||
SettingHandler.setWarp(p.getLocation(), p, warpName);
|
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||||
} else {
|
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -4,26 +4,21 @@ import me.william278.huskhomes2.HuskHomes;
|
|||||||
import me.william278.huskhomes2.MessageManager;
|
import me.william278.huskhomes2.MessageManager;
|
||||||
import me.william278.huskhomes2.teleport.TeleportManager;
|
import me.william278.huskhomes2.teleport.TeleportManager;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class SpawnCommand extends CommandBase {
|
public class SpawnCommand extends CommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||||
if (sender instanceof Player) {
|
if (HuskHomes.settings.doSpawnCommand()) {
|
||||||
Player p = (Player) sender;
|
if (TeleportManager.spawnLocation != null) {
|
||||||
if (HuskHomes.settings.doSpawnCommand()) {
|
TeleportManager.queueTimedTeleport(p, TeleportManager.spawnLocation);
|
||||||
if (TeleportManager.spawnLocation != null) {
|
|
||||||
TeleportManager.queueTimedTeleport(p, TeleportManager.spawnLocation);
|
|
||||||
} else {
|
|
||||||
MessageManager.sendMessage(p, "error_spawn_undefined");
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
MessageManager.sendMessage(p, "error_command_disabled");
|
MessageManager.sendMessage(p, "error_spawn_undefined");
|
||||||
}
|
}
|
||||||
return true;
|
} else {
|
||||||
|
MessageManager.sendMessage(p, "error_command_disabled");
|
||||||
}
|
}
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -19,70 +19,66 @@ import java.util.List;
|
|||||||
public class TpCommand extends CommandBase {
|
public class TpCommand extends CommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||||
if (sender instanceof Player) {
|
if (args.length >= 1) {
|
||||||
Player p = (Player) sender;
|
switch (args.length) {
|
||||||
if (args.length >= 1) {
|
case 1:
|
||||||
switch (args.length) {
|
String targetPlayer = args[0];
|
||||||
case 1:
|
TeleportManager.teleportPlayer(p, targetPlayer);
|
||||||
String targetPlayer = args[0];
|
return true;
|
||||||
TeleportManager.teleportPlayer(p, targetPlayer);
|
case 3:
|
||||||
return true;
|
try {
|
||||||
case 3:
|
double x = Double.parseDouble(args[0]);
|
||||||
try {
|
double y = Double.parseDouble(args[1]);
|
||||||
double x = Double.parseDouble(args[0]);
|
double z = Double.parseDouble(args[2]);
|
||||||
double y = Double.parseDouble(args[1]);
|
TeleportationPoint teleportationPoint = new TeleportationPoint(p.getWorld().getName(), x, y, z, 0F, 0F, HuskHomes.settings.getServerID());
|
||||||
double z = Double.parseDouble(args[2]);
|
TeleportManager.teleportPlayer(p, teleportationPoint);
|
||||||
TeleportationPoint teleportationPoint = new TeleportationPoint(p.getWorld().getName(), x, y, z, 0F, 0F, HuskHomes.settings.getServerID());
|
} catch (Exception e) {
|
||||||
TeleportManager.teleportPlayer(p, teleportationPoint);
|
MessageManager.sendMessage(p, "error_invalid_syntax", "/tp <x> <y> <z> [world] [server]");
|
||||||
} catch (Exception e) {
|
}
|
||||||
|
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] [server]");
|
MessageManager.sendMessage(p, "error_invalid_syntax", "/tp <x> <y> <z> [world] [server]");
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return true;
|
TeleportationPoint teleportationPoint = new TeleportationPoint(worldName, x, y, z, 0F, 0F, HuskHomes.settings.getServerID());
|
||||||
case 4:
|
TeleportManager.teleportPlayer(p, teleportationPoint);
|
||||||
|
} catch (Exception e) {
|
||||||
|
MessageManager.sendMessage(p, "error_invalid_syntax", "/tp <x> <y> <z> [world] [server]");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
case 5:
|
||||||
|
if (HuskHomes.settings.doBungee()) {
|
||||||
try {
|
try {
|
||||||
double x = Double.parseDouble(args[0]);
|
double x = Double.parseDouble(args[0]);
|
||||||
double y = Double.parseDouble(args[1]);
|
double y = Double.parseDouble(args[1]);
|
||||||
double z = Double.parseDouble(args[2]);
|
double z = Double.parseDouble(args[2]);
|
||||||
String worldName = args[3];
|
String worldName = args[3];
|
||||||
|
String serverName = args[4];
|
||||||
if (Bukkit.getWorld(worldName) == null) {
|
if (Bukkit.getWorld(worldName) == null) {
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", "/tp <x> <y> <z> [world] [server]");
|
MessageManager.sendMessage(p, "error_invalid_syntax", "/tp <x> <y> <z> <world> <server>");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
TeleportationPoint teleportationPoint = new TeleportationPoint(worldName, x, y, z, 0F, 0F, HuskHomes.settings.getServerID());
|
TeleportationPoint teleportationPoint = new TeleportationPoint(worldName, x, y, z, 0F, 0F, serverName);
|
||||||
TeleportManager.teleportPlayer(p, teleportationPoint);
|
TeleportManager.teleportPlayer(p, teleportationPoint);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", "/tp <x> <y> <z> [world] [server]");
|
MessageManager.sendMessage(p, "error_invalid_syntax", "/tp <x> <y> <z> <world> <server>");
|
||||||
}
|
}
|
||||||
return true;
|
} else {
|
||||||
case 5:
|
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||||
if (HuskHomes.settings.doBungee()) {
|
}
|
||||||
try {
|
return true;
|
||||||
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;
|
} else {
|
||||||
|
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||||
}
|
}
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Tab implements TabCompleter {
|
public static class Tab implements TabCompleter {
|
||||||
|
|||||||
@@ -3,23 +3,18 @@ package me.william278.huskhomes2.commands;
|
|||||||
import me.william278.huskhomes2.MessageManager;
|
import me.william278.huskhomes2.MessageManager;
|
||||||
import me.william278.huskhomes2.teleport.TeleportRequestHandler;
|
import me.william278.huskhomes2.teleport.TeleportRequestHandler;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class TpaCommand extends CommandBase {
|
public class TpaCommand extends CommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||||
if (sender instanceof Player) {
|
if (args.length == 1) {
|
||||||
Player p = (Player) sender;
|
String targetPlayer = args[0];
|
||||||
if (args.length == 1) {
|
TeleportRequestHandler.sendTeleportToRequest(p, targetPlayer);
|
||||||
String targetPlayer = args[0];
|
} else {
|
||||||
TeleportRequestHandler.sendTeleportToRequest(p, targetPlayer);
|
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||||
} else {
|
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,18 +2,13 @@ package me.william278.huskhomes2.commands;
|
|||||||
|
|
||||||
import me.william278.huskhomes2.teleport.TeleportRequestHandler;
|
import me.william278.huskhomes2.teleport.TeleportRequestHandler;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class TpacceptCommand extends CommandBase {
|
public class TpacceptCommand extends CommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||||
if (sender instanceof Player) {
|
TeleportRequestHandler.replyTpRequest(p, true);
|
||||||
Player p = (Player) sender;
|
return true;
|
||||||
TeleportRequestHandler.replyTpRequest(p, true);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,23 +3,18 @@ package me.william278.huskhomes2.commands;
|
|||||||
import me.william278.huskhomes2.MessageManager;
|
import me.william278.huskhomes2.MessageManager;
|
||||||
import me.william278.huskhomes2.teleport.TeleportRequestHandler;
|
import me.william278.huskhomes2.teleport.TeleportRequestHandler;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class TpahereCommand extends CommandBase {
|
public class TpahereCommand extends CommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||||
if (sender instanceof Player) {
|
if (args.length == 1) {
|
||||||
Player p = (Player) sender;
|
String targetPlayer = args[0];
|
||||||
if (args.length == 1) {
|
TeleportRequestHandler.sendTeleportHereRequest(p, targetPlayer);
|
||||||
String targetPlayer = args[0];
|
} else {
|
||||||
TeleportRequestHandler.sendTeleportHereRequest(p, targetPlayer);
|
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||||
} else {
|
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,18 +2,13 @@ package me.william278.huskhomes2.commands;
|
|||||||
|
|
||||||
import me.william278.huskhomes2.teleport.TeleportRequestHandler;
|
import me.william278.huskhomes2.teleport.TeleportRequestHandler;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class TpdenyCommand extends CommandBase {
|
public class TpdenyCommand extends CommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||||
if (sender instanceof Player) {
|
TeleportRequestHandler.replyTpRequest(p, false);
|
||||||
Player p = (Player) sender;
|
return true;
|
||||||
TeleportRequestHandler.replyTpRequest(p, false);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,23 +3,18 @@ package me.william278.huskhomes2.commands;
|
|||||||
import me.william278.huskhomes2.MessageManager;
|
import me.william278.huskhomes2.MessageManager;
|
||||||
import me.william278.huskhomes2.teleport.TeleportManager;
|
import me.william278.huskhomes2.teleport.TeleportManager;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class TphereCommand extends CommandBase {
|
public class TphereCommand extends CommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||||
if (sender instanceof Player) {
|
if (args.length == 1) {
|
||||||
Player p = (Player) sender;
|
String targetPlayer = args[0];
|
||||||
if (args.length == 1) {
|
TeleportManager.teleportHere(p, targetPlayer);
|
||||||
String targetPlayer = args[0];
|
} else {
|
||||||
TeleportManager.teleportHere(p, targetPlayer);
|
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||||
} else {
|
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -20,27 +20,23 @@ import java.util.List;
|
|||||||
public class WarpCommand extends CommandBase {
|
public class WarpCommand extends CommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||||
if (sender instanceof Player) {
|
if (HuskHomes.settings.doWarpCommand()) {
|
||||||
Player p = (Player) sender;
|
if (args.length == 1) {
|
||||||
if (HuskHomes.settings.doWarpCommand()) {
|
String warpName = args[0];
|
||||||
if (args.length == 1) {
|
if (DataManager.warpExists(warpName)) {
|
||||||
String warpName = args[0];
|
Warp warp = DataManager.getWarp(warpName);
|
||||||
if (DataManager.warpExists(warpName)) {
|
TeleportManager.queueTimedTeleport(p, warp);
|
||||||
Warp warp = DataManager.getWarp(warpName);
|
|
||||||
TeleportManager.queueTimedTeleport(p, warp);
|
|
||||||
} else {
|
|
||||||
MessageManager.sendMessage(p, "error_warp_invalid", warpName);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
ListHandler.displayWarpList(p, 1);
|
MessageManager.sendMessage(p, "error_warp_invalid", warpName);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
MessageManager.sendMessage(p, "error_command_disabled");
|
ListHandler.displayWarpList(p, 1);
|
||||||
}
|
}
|
||||||
return true;
|
} else {
|
||||||
|
MessageManager.sendMessage(p, "error_command_disabled");
|
||||||
}
|
}
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Tab implements TabCompleter {
|
public static class Tab implements TabCompleter {
|
||||||
|
|||||||
@@ -3,28 +3,23 @@ package me.william278.huskhomes2.commands;
|
|||||||
import me.william278.huskhomes2.MessageManager;
|
import me.william278.huskhomes2.MessageManager;
|
||||||
import me.william278.huskhomes2.teleport.ListHandler;
|
import me.william278.huskhomes2.teleport.ListHandler;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class WarplistCommand extends CommandBase {
|
public class WarplistCommand extends CommandBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||||
if (sender instanceof Player) {
|
int pageNo = 1;
|
||||||
Player p = (Player) sender;
|
if (args.length == 1) {
|
||||||
int pageNo = 1;
|
try {
|
||||||
if (args.length == 1) {
|
pageNo = Integer.parseInt(args[0]);
|
||||||
try {
|
} catch (Exception e) {
|
||||||
pageNo = Integer.parseInt(args[0]);
|
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||||
} catch (Exception e) {
|
return true;
|
||||||
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ListHandler.displayWarpList(p, pageNo);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
ListHandler.displayWarpList(p, pageNo);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
package me.william278.huskhomes2.data;
|
package me.william278.huskhomes2.data;
|
||||||
|
|
||||||
import me.william278.huskhomes2.HuskHomes;
|
import me.william278.huskhomes2.HuskHomes;
|
||||||
import me.william278.huskhomes2.data.logging.Errors;
|
|
||||||
import me.william278.huskhomes2.teleport.points.Home;
|
import me.william278.huskhomes2.teleport.points.Home;
|
||||||
import me.william278.huskhomes2.teleport.points.TeleportationPoint;
|
import me.william278.huskhomes2.teleport.points.TeleportationPoint;
|
||||||
import me.william278.huskhomes2.teleport.points.Warp;
|
import me.william278.huskhomes2.teleport.points.Warp;
|
||||||
@@ -27,7 +26,7 @@ public class DataManager {
|
|||||||
|
|
||||||
public static String createLocationsTable = "";
|
public static String createLocationsTable = "";
|
||||||
|
|
||||||
public static String createHomesTable = "CREATE TABLE IF NOT EXISTS " + HuskHomes.settings.getHomesDataTable() + " (" +
|
public static final String createHomesTable = "CREATE TABLE IF NOT EXISTS " + HuskHomes.settings.getHomesDataTable() + " (" +
|
||||||
"`player_id` integer NOT NULL," +
|
"`player_id` integer NOT NULL," +
|
||||||
"`location_id` integer NOT NULL," +
|
"`location_id` integer NOT NULL," +
|
||||||
"`name` varchar(16) NOT NULL," +
|
"`name` varchar(16) NOT NULL," +
|
||||||
@@ -38,7 +37,7 @@ public class DataManager {
|
|||||||
"FOREIGN KEY (`location_id`) REFERENCES " + HuskHomes.settings.getLocationsDataTable() + " (`location_id`) ON DELETE CASCADE ON UPDATE NO ACTION" +
|
"FOREIGN KEY (`location_id`) REFERENCES " + HuskHomes.settings.getLocationsDataTable() + " (`location_id`) ON DELETE CASCADE ON UPDATE NO ACTION" +
|
||||||
");";
|
");";
|
||||||
|
|
||||||
public static String createWarpsTable = "CREATE TABLE IF NOT EXISTS " + HuskHomes.settings.getWarpsDataTable() + " (" +
|
public static final String createWarpsTable = "CREATE TABLE IF NOT EXISTS " + HuskHomes.settings.getWarpsDataTable() + " (" +
|
||||||
"`location_id` integer NOT NULL," +
|
"`location_id` integer NOT NULL," +
|
||||||
"`name` varchar(16) NOT NULL UNIQUE," +
|
"`name` varchar(16) NOT NULL UNIQUE," +
|
||||||
"`description` varchar(255) NOT NULL," +
|
"`description` varchar(255) NOT NULL," +
|
||||||
@@ -80,7 +79,7 @@ public class DataManager {
|
|||||||
return null; // If the player doesn't exist, playerID will be null
|
return null; // If the player doesn't exist, playerID will be null
|
||||||
}
|
}
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -106,7 +105,7 @@ public class DataManager {
|
|||||||
return null; // If the player doesn't exist, playerID will be null
|
return null; // If the player doesn't exist, playerID will be null
|
||||||
}
|
}
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -133,7 +132,7 @@ public class DataManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -170,7 +169,7 @@ public class DataManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -198,7 +197,7 @@ public class DataManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -274,7 +273,7 @@ public class DataManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -305,7 +304,7 @@ public class DataManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -336,7 +335,7 @@ public class DataManager {
|
|||||||
}
|
}
|
||||||
return warps;
|
return warps;
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -370,7 +369,7 @@ public class DataManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -395,7 +394,7 @@ public class DataManager {
|
|||||||
Bukkit.getLogger().severe("Failed to obtain home teleportation location ID");
|
Bukkit.getLogger().severe("Failed to obtain home teleportation location ID");
|
||||||
}
|
}
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -433,7 +432,7 @@ public class DataManager {
|
|||||||
Bukkit.getLogger().severe("Failed to obtain warp teleportation location ID");
|
Bukkit.getLogger().severe("Failed to obtain warp teleportation location ID");
|
||||||
}
|
}
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -518,7 +517,7 @@ public class DataManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -540,7 +539,7 @@ public class DataManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -573,7 +572,7 @@ public class DataManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -600,7 +599,7 @@ public class DataManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -627,7 +626,7 @@ public class DataManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
package me.william278.huskhomes2.data;
|
package me.william278.huskhomes2.data;
|
||||||
|
|
||||||
import me.william278.huskhomes2.HuskHomes;
|
import me.william278.huskhomes2.HuskHomes;
|
||||||
import me.william278.huskhomes2.data.logging.Error;
|
|
||||||
import me.william278.huskhomes2.data.logging.Errors;
|
|
||||||
import me.william278.huskhomes2.teleport.points.Home;
|
import me.william278.huskhomes2.teleport.points.Home;
|
||||||
import me.william278.huskhomes2.teleport.points.TeleportationPoint;
|
import me.william278.huskhomes2.teleport.points.TeleportationPoint;
|
||||||
import me.william278.huskhomes2.teleport.points.Warp;
|
import me.william278.huskhomes2.teleport.points.Warp;
|
||||||
@@ -60,7 +58,7 @@ public abstract class Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -82,7 +80,7 @@ public abstract class Database {
|
|||||||
ps.setBoolean(5, home.isPublic());
|
ps.setBoolean(5, home.isPublic());
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +102,7 @@ public abstract class Database {
|
|||||||
ps.setString(3, warp.getDescription());
|
ps.setString(3, warp.getDescription());
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,7 +120,7 @@ public abstract class Database {
|
|||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
|
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,7 +139,7 @@ public abstract class Database {
|
|||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
|
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,7 +160,7 @@ public abstract class Database {
|
|||||||
|
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,7 +181,7 @@ public abstract class Database {
|
|||||||
|
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,7 +202,7 @@ public abstract class Database {
|
|||||||
|
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,7 +217,7 @@ public abstract class Database {
|
|||||||
ps.setInt(2, playerID);
|
ps.setInt(2, playerID);
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,7 +232,7 @@ public abstract class Database {
|
|||||||
ps.setInt(2, playerID);
|
ps.setInt(2, playerID);
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -249,7 +247,7 @@ public abstract class Database {
|
|||||||
ps.setInt(2, playerID);
|
ps.setInt(2, playerID);
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,7 +262,7 @@ public abstract class Database {
|
|||||||
ps.setInt(2, playerID);
|
ps.setInt(2, playerID);
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -281,7 +279,7 @@ public abstract class Database {
|
|||||||
|
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -300,7 +298,7 @@ public abstract class Database {
|
|||||||
ps.setInt(3, ownerID);
|
ps.setInt(3, ownerID);
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,7 +320,7 @@ public abstract class Database {
|
|||||||
ps.setInt(3, ownerID);
|
ps.setInt(3, ownerID);
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -343,7 +341,7 @@ public abstract class Database {
|
|||||||
ps.setString(2, warpName);
|
ps.setString(2, warpName);
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Update the description of a home
|
// Update the description of a home
|
||||||
@@ -361,7 +359,7 @@ public abstract class Database {
|
|||||||
ps.setInt(3, ownerID);
|
ps.setInt(3, ownerID);
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -379,7 +377,7 @@ public abstract class Database {
|
|||||||
ps.setString(2, warpName);
|
ps.setString(2, warpName);
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -399,7 +397,7 @@ public abstract class Database {
|
|||||||
|
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -418,7 +416,7 @@ public abstract class Database {
|
|||||||
|
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -439,7 +437,7 @@ public abstract class Database {
|
|||||||
ps.setInt(2, playerID);
|
ps.setInt(2, playerID);
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -461,7 +459,7 @@ public abstract class Database {
|
|||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
|
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -476,7 +474,7 @@ public abstract class Database {
|
|||||||
ps.setInt(1, playerID);
|
ps.setInt(1, playerID);
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -491,7 +489,7 @@ public abstract class Database {
|
|||||||
ps.setInt(1, playerID);
|
ps.setInt(1, playerID);
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
-1
@@ -1,14 +1,19 @@
|
|||||||
package me.william278.huskhomes2.data.logging;
|
package me.william278.huskhomes2.data;
|
||||||
|
|
||||||
import me.william278.huskhomes2.HuskHomes;
|
import me.william278.huskhomes2.HuskHomes;
|
||||||
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class Error {
|
public class Error {
|
||||||
|
public static final String SQL_CONNECTION_EXECUTE = "Couldn't execute MySQL statement: ";
|
||||||
|
public static final String SQL_CONNECTION_CLOSE = "Failed to close MySQL connection: ";
|
||||||
|
public static final String SQL_NO_CONNECTION = "Unable to retrieve MYSQL connection: ";
|
||||||
|
public static final String SQL_NO_TABLE_FOUND = "Database Error: No Table Found";
|
||||||
|
|
||||||
public static void execute(HuskHomes plugin, Exception ex){
|
public static void execute(HuskHomes plugin, Exception ex){
|
||||||
plugin.getLogger().log(Level.SEVERE, "Couldn't execute MySQL statement: ", ex);
|
plugin.getLogger().log(Level.SEVERE, "Couldn't execute MySQL statement: ", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void close(HuskHomes plugin, Exception ex){
|
public static void close(HuskHomes plugin, Exception ex){
|
||||||
plugin.getLogger().log(Level.SEVERE, "Failed to close MySQL connection: ", ex);
|
plugin.getLogger().log(Level.SEVERE, "Failed to close MySQL connection: ", ex);
|
||||||
}
|
}
|
||||||
@@ -12,7 +12,7 @@ import java.util.logging.Level;
|
|||||||
|
|
||||||
public class SQL extends Database {
|
public class SQL extends Database {
|
||||||
|
|
||||||
final String SQLiteDatabaseName = "HuskHomesData";
|
private final String SQLiteDatabaseName = "HuskHomesData";
|
||||||
|
|
||||||
private Connection connection;
|
private Connection connection;
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
package me.william278.huskhomes2.data.logging;
|
|
||||||
|
|
||||||
public class Errors {
|
|
||||||
public static String sqlConnectionExecute(){
|
|
||||||
return "Couldn't execute MySQL statement: ";
|
|
||||||
}
|
|
||||||
public static String sqlConnectionClose(){
|
|
||||||
return "Failed to close MySQL connection: ";
|
|
||||||
}
|
|
||||||
public static String noSQLConnection(){
|
|
||||||
return "Unable to retrieve MYSQL connection: ";
|
|
||||||
}
|
|
||||||
public static String noTableFound(){
|
|
||||||
return "Database Error: No Table Found";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user