mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-01 22:16:08 +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.points.TeleportationPoint;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class BackCommand extends CommandBase {
|
||||
|
||||
@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;
|
||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||
TeleportationPoint lastPosition = DataManager.getPlayerLastPosition(p);
|
||||
if (lastPosition != null) {
|
||||
TeleportManager.queueTimedTeleport(p, lastPosition);
|
||||
} else {
|
||||
MessageManager.sendMessage(p, "error_no_last_position");
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -5,12 +5,23 @@ import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
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
|
||||
* @param command Command for registration
|
||||
|
||||
@@ -3,24 +3,19 @@ package me.william278.huskhomes2.commands;
|
||||
import me.william278.huskhomes2.MessageManager;
|
||||
import me.william278.huskhomes2.teleport.SettingHandler;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class DelhomeCommand extends CommandBase {
|
||||
|
||||
@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];
|
||||
SettingHandler.deleteHome(p, homeName);
|
||||
} else {
|
||||
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||
}
|
||||
return true;
|
||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||
if (args.length == 1) {
|
||||
String homeName = args[0];
|
||||
SettingHandler.deleteHome(p, homeName);
|
||||
} else {
|
||||
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,24 +3,19 @@ package me.william278.huskhomes2.commands;
|
||||
import me.william278.huskhomes2.MessageManager;
|
||||
import me.william278.huskhomes2.teleport.SettingHandler;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class DelwarpCommand extends CommandBase {
|
||||
|
||||
@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;
|
||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||
if (args.length == 1) {
|
||||
String warpName = args[0];
|
||||
SettingHandler.deleteWarp(p, warpName);
|
||||
} else {
|
||||
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -28,192 +28,188 @@ import java.util.List;
|
||||
public class EdithomeCommand extends CommandBase implements TabCompleter {
|
||||
|
||||
@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":
|
||||
Location newLocation = p.getLocation();
|
||||
TeleportationPoint newTeleportLocation = new TeleportationPoint(newLocation, HuskHomes.settings.getServerID());
|
||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||
if (args.length >= 1) {
|
||||
String homeName = args[0];
|
||||
if (DataManager.homeExists(p.getName(), homeName)) {
|
||||
if (args.length >= 2) {
|
||||
switch (args[1]) {
|
||||
case "location":
|
||||
Location newLocation = p.getLocation();
|
||||
TeleportationPoint newTeleportLocation = new TeleportationPoint(newLocation, HuskHomes.settings.getServerID());
|
||||
|
||||
// Remove old marker if on dynmap
|
||||
Home locationMovedHome = DataManager.getHome(p.getName(), homeName);
|
||||
if (locationMovedHome.isPublic() && HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
||||
DynMapIntegration.removeDynamicMapMarker(homeName, p.getName());
|
||||
// Remove old marker if on dynmap
|
||||
Home locationMovedHome = DataManager.getHome(p.getName(), homeName);
|
||||
if (locationMovedHome.isPublic() && HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
PlayerRelocateHomeEvent relocateHomeEvent = new PlayerRelocateHomeEvent(p, locationMovedHome, newTeleportLocation);
|
||||
Bukkit.getPluginManager().callEvent(relocateHomeEvent);
|
||||
if (relocateHomeEvent.isCancelled()) {
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
// Remove old marker if on the Dynmap
|
||||
if (descriptionChangedHome.isPublic() && HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
||||
DynMapIntegration.removeDynamicMapMarker(homeName, p.getName());
|
||||
}
|
||||
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();
|
||||
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;
|
||||
}
|
||||
// Update description
|
||||
DataManager.updateHomeDescription(p.getName(), homeName, newDescriptionString);
|
||||
|
||||
// Remove old marker if on the Dynmap
|
||||
if (descriptionChangedHome.isPublic() && HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
||||
// 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 {
|
||||
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());
|
||||
}
|
||||
|
||||
// Update description
|
||||
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);
|
||||
DataManager.updateHomeName(p.getName(), homeName, newName);
|
||||
PublichomeCommand.updatePublicHomeTabCache();
|
||||
} else {
|
||||
MessageManager.sendMessage(p, "error_invalid_syntax", "/edithome <home> description <new description>");
|
||||
DataManager.updateHomeName(p.getName(), homeName, newName);
|
||||
}
|
||||
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());
|
||||
}
|
||||
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>");
|
||||
renamedHome.setName(newName);
|
||||
if (renamedHome.isPublic() && HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
||||
DynMapIntegration.addDynamicMapMarker(renamedHome);
|
||||
}
|
||||
return true;
|
||||
case "public":
|
||||
Home privateHome = DataManager.getHome(p.getName(), homeName);
|
||||
if (!privateHome.isPublic()) {
|
||||
if (HuskHomes.settings.doEconomy()) {
|
||||
double publicHomeCost = HuskHomes.settings.getPublicHomeCost();
|
||||
if (publicHomeCost > 0) {
|
||||
if (!VaultIntegration.takeMoney(p, publicHomeCost)) {
|
||||
MessageManager.sendMessage(p, "error_insufficient_funds", VaultIntegration.format(publicHomeCost));
|
||||
return true;
|
||||
} else {
|
||||
MessageManager.sendMessage(p, "edit_home_privacy_public_success_economy", homeName, VaultIntegration.format(publicHomeCost));
|
||||
}
|
||||
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;
|
||||
case "public":
|
||||
Home privateHome = DataManager.getHome(p.getName(), homeName);
|
||||
if (!privateHome.isPublic()) {
|
||||
if (HuskHomes.settings.doEconomy()) {
|
||||
double publicHomeCost = HuskHomes.settings.getPublicHomeCost();
|
||||
if (publicHomeCost > 0) {
|
||||
if (!VaultIntegration.takeMoney(p, publicHomeCost)) {
|
||||
MessageManager.sendMessage(p, "error_insufficient_funds", VaultIntegration.format(publicHomeCost));
|
||||
return true;
|
||||
} else {
|
||||
MessageManager.sendMessage(p, "edit_home_privacy_public_success", homeName);
|
||||
MessageManager.sendMessage(p, "edit_home_privacy_public_success_economy", homeName, VaultIntegration.format(publicHomeCost));
|
||||
}
|
||||
} else {
|
||||
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 {
|
||||
MessageManager.sendMessage(p, "error_edit_home_privacy_already_public", homeName);
|
||||
MessageManager.sendMessage(p, "edit_home_privacy_public_success", homeName);
|
||||
}
|
||||
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);
|
||||
PlayerMakeHomePublicEvent makeHomePublicEvent = new PlayerMakeHomePublicEvent(p, privateHome);
|
||||
Bukkit.getPluginManager().callEvent(makeHomePublicEvent);
|
||||
if (makeHomePublicEvent.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
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;
|
||||
DataManager.updateHomePrivacy(p.getName(), homeName, true);
|
||||
PublichomeCommand.updatePublicHomeTabCache();
|
||||
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showPublicHomesOnDynmap()) {
|
||||
DynMapIntegration.addDynamicMapMarker(privateHome);
|
||||
}
|
||||
} else {
|
||||
MessageManager.sendMessage(p, "error_edit_home_privacy_already_public", homeName);
|
||||
}
|
||||
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 {
|
||||
MessageManager.sendMessage(p, "error_home_invalid", homeName);
|
||||
Home home = DataManager.getHome(p.getName(), homeName);
|
||||
EditingHandler.showEditHomeOptions(p, home);
|
||||
return true;
|
||||
}
|
||||
} 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
|
||||
|
||||
@@ -25,139 +25,135 @@ import java.util.List;
|
||||
public class EditwarpCommand extends CommandBase implements TabCompleter {
|
||||
|
||||
@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":
|
||||
Location newLocation = p.getLocation();
|
||||
TeleportationPoint newTeleportLocation = new TeleportationPoint(newLocation, HuskHomes.settings.getServerID());
|
||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||
if (args.length >= 1) {
|
||||
String warpName = args[0];
|
||||
if (DataManager.warpExists(warpName)) {
|
||||
if (args.length >= 2) {
|
||||
switch (args[1]) {
|
||||
case "location":
|
||||
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()) {
|
||||
DynMapIntegration.removeDynamicMapMarker(warpName);
|
||||
}
|
||||
|
||||
PlayerRelocateWarpEvent relocateWarpEvent = new PlayerRelocateWarpEvent(p, locationMovedWarp, newTeleportLocation);
|
||||
Bukkit.getPluginManager().callEvent(relocateWarpEvent);
|
||||
if (relocateWarpEvent.isCancelled()) {
|
||||
// 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;
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
DynMapIntegration.removeDynamicMapMarker(warpName);
|
||||
}
|
||||
return true;
|
||||
case "description":
|
||||
if (args.length >= 3) {
|
||||
Warp descriptionChangedWarp = DataManager.getWarp(warpName);
|
||||
DataManager.updateWarpName(warpName, newName);
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
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>");
|
||||
renamedWarp.setName(newName);
|
||||
if (HuskHomes.settings.doDynmap() && HuskHomes.settings.showWarpsOnDynmap()) {
|
||||
DynMapIntegration.addDynamicMapMarker(renamedWarp);
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
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 {
|
||||
MessageManager.sendMessage(p, "error_warp_invalid", warpName);
|
||||
Warp warp = DataManager.getWarp(warpName);
|
||||
EditingHandler.showEditWarpOptions(p, warp);
|
||||
return true;
|
||||
}
|
||||
} 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
|
||||
|
||||
@@ -21,31 +21,27 @@ import java.util.UUID;
|
||||
public class HomeCommand extends CommandBase {
|
||||
|
||||
@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, homeName)) {
|
||||
Home home = DataManager.getHome(p.getName(), homeName);
|
||||
TeleportManager.queueTimedTeleport(p, home);
|
||||
} else {
|
||||
MessageManager.sendMessage(p, "error_home_invalid", homeName);
|
||||
}
|
||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||
if (args.length == 1) {
|
||||
String homeName = args[0];
|
||||
if (DataManager.homeExists(p, homeName)) {
|
||||
Home home = DataManager.getHome(p.getName(), homeName);
|
||||
TeleportManager.queueTimedTeleport(p, home);
|
||||
} 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);
|
||||
MessageManager.sendMessage(p, "error_home_invalid", homeName);
|
||||
}
|
||||
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 {
|
||||
|
||||
@@ -3,28 +3,23 @@ package me.william278.huskhomes2.commands;
|
||||
import me.william278.huskhomes2.MessageManager;
|
||||
import me.william278.huskhomes2.teleport.ListHandler;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class HomelistCommand extends CommandBase {
|
||||
|
||||
@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;
|
||||
}
|
||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||
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.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;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onCommand(Player player, Command command, String label, String[] args) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
if (args.length == 1) {
|
||||
|
||||
@@ -33,33 +33,29 @@ public class PublichomeCommand extends CommandBase implements TabCompleter {
|
||||
}
|
||||
|
||||
@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_\\-]+")) {
|
||||
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);
|
||||
}
|
||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||
if (args.length == 1) {
|
||||
String publicHome = args[0];
|
||||
if (publicHome.matches("[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_invalid_syntax", command.getUsage());
|
||||
MessageManager.sendMessage(p, "error_public_home_invalid", ownerName, homeName);
|
||||
}
|
||||
} 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
|
||||
|
||||
@@ -3,28 +3,23 @@ package me.william278.huskhomes2.commands;
|
||||
import me.william278.huskhomes2.MessageManager;
|
||||
import me.william278.huskhomes2.teleport.ListHandler;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PublichomelistCommand extends CommandBase {
|
||||
|
||||
@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;
|
||||
}
|
||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||
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;
|
||||
ListHandler.displayPublicHomeList(p, pageNo);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,26 +5,21 @@ import me.william278.huskhomes2.MessageManager;
|
||||
import me.william278.huskhomes2.teleport.TeleportManager;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class RtpCommand extends CommandBase {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
if (HuskHomes.settings.doRtpCommand()) {
|
||||
if (p.getWorld().getEnvironment() == World.Environment.NORMAL) {
|
||||
TeleportManager.queueRandomTeleport(p);
|
||||
} else {
|
||||
MessageManager.sendMessage(p, "error_rtp_invalid_dimension");
|
||||
}
|
||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||
if (HuskHomes.settings.doRtpCommand()) {
|
||||
if (p.getWorld().getEnvironment() == World.Environment.NORMAL) {
|
||||
TeleportManager.queueRandomTeleport(p);
|
||||
} 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.teleport.SettingHandler;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class SethomeCommand extends CommandBase {
|
||||
|
||||
@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];
|
||||
SettingHandler.setHome(p.getLocation(), p, homeName);
|
||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||
if (args.length == 1) {
|
||||
String homeName = args[0];
|
||||
SettingHandler.setHome(p.getLocation(), p, homeName);
|
||||
} else {
|
||||
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 {
|
||||
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 {
|
||||
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||
}
|
||||
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.teleport.SettingHandler;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class SetspawnCommand extends CommandBase {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
if (HuskHomes.settings.doSpawnCommand()) {
|
||||
SettingHandler.setSpawnLocation(p.getLocation());
|
||||
p.getLocation().getWorld().setSpawnLocation(p.getLocation());
|
||||
MessageManager.sendMessage(p, "set_spawn_success");
|
||||
} else {
|
||||
MessageManager.sendMessage(p, "error_command_disabled");
|
||||
}
|
||||
return true;
|
||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||
if (HuskHomes.settings.doSpawnCommand()) {
|
||||
SettingHandler.setSpawnLocation(p.getLocation());
|
||||
p.getLocation().getWorld().setSpawnLocation(p.getLocation());
|
||||
MessageManager.sendMessage(p, "set_spawn_success");
|
||||
} else {
|
||||
MessageManager.sendMessage(p, "error_command_disabled");
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -3,24 +3,19 @@ package me.william278.huskhomes2.commands;
|
||||
import me.william278.huskhomes2.MessageManager;
|
||||
import me.william278.huskhomes2.teleport.SettingHandler;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class SetwarpCommand extends CommandBase {
|
||||
|
||||
@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;
|
||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||
if (args.length == 1) {
|
||||
String warpName = args[0];
|
||||
SettingHandler.setWarp(p.getLocation(), p, warpName);
|
||||
} else {
|
||||
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,26 +4,21 @@ import me.william278.huskhomes2.HuskHomes;
|
||||
import me.william278.huskhomes2.MessageManager;
|
||||
import me.william278.huskhomes2.teleport.TeleportManager;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class SpawnCommand extends CommandBase {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
if (HuskHomes.settings.doSpawnCommand()) {
|
||||
if (TeleportManager.spawnLocation != null) {
|
||||
TeleportManager.queueTimedTeleport(p, TeleportManager.spawnLocation);
|
||||
} else {
|
||||
MessageManager.sendMessage(p, "error_spawn_undefined");
|
||||
}
|
||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||
if (HuskHomes.settings.doSpawnCommand()) {
|
||||
if (TeleportManager.spawnLocation != null) {
|
||||
TeleportManager.queueTimedTeleport(p, TeleportManager.spawnLocation);
|
||||
} 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 {
|
||||
|
||||
@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, HuskHomes.settings.getServerID());
|
||||
TeleportManager.teleportPlayer(p, teleportationPoint);
|
||||
} catch (Exception e) {
|
||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||
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, HuskHomes.settings.getServerID());
|
||||
TeleportManager.teleportPlayer(p, teleportationPoint);
|
||||
} catch (Exception e) {
|
||||
MessageManager.sendMessage(p, "error_invalid_syntax", "/tp <x> <y> <z> [world] [server]");
|
||||
}
|
||||
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]");
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
case 4:
|
||||
TeleportationPoint teleportationPoint = new TeleportationPoint(worldName, x, y, z, 0F, 0F, HuskHomes.settings.getServerID());
|
||||
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 {
|
||||
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]");
|
||||
MessageManager.sendMessage(p, "error_invalid_syntax", "/tp <x> <y> <z> <world> <server>");
|
||||
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);
|
||||
} 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;
|
||||
case 5:
|
||||
if (HuskHomes.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());
|
||||
} else {
|
||||
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static class Tab implements TabCompleter {
|
||||
|
||||
@@ -3,23 +3,18 @@ package me.william278.huskhomes2.commands;
|
||||
import me.william278.huskhomes2.MessageManager;
|
||||
import me.william278.huskhomes2.teleport.TeleportRequestHandler;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class TpaCommand extends CommandBase {
|
||||
|
||||
@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;
|
||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||
if (args.length == 1) {
|
||||
String targetPlayer = args[0];
|
||||
TeleportRequestHandler.sendTeleportToRequest(p, targetPlayer);
|
||||
} else {
|
||||
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -2,18 +2,13 @@ package me.william278.huskhomes2.commands;
|
||||
|
||||
import me.william278.huskhomes2.teleport.TeleportRequestHandler;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class TpacceptCommand extends CommandBase {
|
||||
|
||||
@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;
|
||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||
TeleportRequestHandler.replyTpRequest(p, true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -3,23 +3,18 @@ package me.william278.huskhomes2.commands;
|
||||
import me.william278.huskhomes2.MessageManager;
|
||||
import me.william278.huskhomes2.teleport.TeleportRequestHandler;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class TpahereCommand extends CommandBase {
|
||||
|
||||
@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;
|
||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||
if (args.length == 1) {
|
||||
String targetPlayer = args[0];
|
||||
TeleportRequestHandler.sendTeleportHereRequest(p, targetPlayer);
|
||||
} else {
|
||||
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -2,18 +2,13 @@ package me.william278.huskhomes2.commands;
|
||||
|
||||
import me.william278.huskhomes2.teleport.TeleportRequestHandler;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class TpdenyCommand extends CommandBase {
|
||||
|
||||
@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;
|
||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||
TeleportRequestHandler.replyTpRequest(p, false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -3,23 +3,18 @@ package me.william278.huskhomes2.commands;
|
||||
import me.william278.huskhomes2.MessageManager;
|
||||
import me.william278.huskhomes2.teleport.TeleportManager;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class TphereCommand extends CommandBase {
|
||||
|
||||
@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.teleportHere(p, targetPlayer);
|
||||
} else {
|
||||
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||
}
|
||||
return true;
|
||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||
if (args.length == 1) {
|
||||
String targetPlayer = args[0];
|
||||
TeleportManager.teleportHere(p, targetPlayer);
|
||||
} else {
|
||||
MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage());
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -20,27 +20,23 @@ import java.util.List;
|
||||
public class WarpCommand extends CommandBase {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
if (HuskHomes.settings.doWarpCommand()) {
|
||||
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);
|
||||
}
|
||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||
if (HuskHomes.settings.doWarpCommand()) {
|
||||
if (args.length == 1) {
|
||||
String warpName = args[0];
|
||||
if (DataManager.warpExists(warpName)) {
|
||||
Warp warp = DataManager.getWarp(warpName);
|
||||
TeleportManager.queueTimedTeleport(p, warp);
|
||||
} else {
|
||||
ListHandler.displayWarpList(p, 1);
|
||||
MessageManager.sendMessage(p, "error_warp_invalid", warpName);
|
||||
}
|
||||
} 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 {
|
||||
|
||||
@@ -3,28 +3,23 @@ package me.william278.huskhomes2.commands;
|
||||
import me.william278.huskhomes2.MessageManager;
|
||||
import me.william278.huskhomes2.teleport.ListHandler;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class WarplistCommand extends CommandBase {
|
||||
|
||||
@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;
|
||||
}
|
||||
protected boolean onCommand(Player p, Command command, String label, String[] args) {
|
||||
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;
|
||||
ListHandler.displayWarpList(p, pageNo);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package me.william278.huskhomes2.data;
|
||||
|
||||
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.TeleportationPoint;
|
||||
import me.william278.huskhomes2.teleport.points.Warp;
|
||||
@@ -27,7 +26,7 @@ public class DataManager {
|
||||
|
||||
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," +
|
||||
"`location_id` integer 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" +
|
||||
");";
|
||||
|
||||
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," +
|
||||
"`name` varchar(16) NOT NULL UNIQUE," +
|
||||
"`description` varchar(255) NOT NULL," +
|
||||
@@ -80,7 +79,7 @@ public class DataManager {
|
||||
return null; // If the player doesn't exist, playerID will be null
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
||||
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -106,7 +105,7 @@ public class DataManager {
|
||||
return null; // If the player doesn't exist, playerID will be null
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
||||
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -133,7 +132,7 @@ public class DataManager {
|
||||
return null;
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
||||
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -170,7 +169,7 @@ public class DataManager {
|
||||
return null;
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
||||
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -198,7 +197,7 @@ public class DataManager {
|
||||
return null;
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
||||
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -274,7 +273,7 @@ public class DataManager {
|
||||
return null;
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
||||
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -305,7 +304,7 @@ public class DataManager {
|
||||
return null;
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
||||
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -336,7 +335,7 @@ public class DataManager {
|
||||
}
|
||||
return warps;
|
||||
} catch (SQLException ex) {
|
||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
||||
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -370,7 +369,7 @@ public class DataManager {
|
||||
return null;
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
||||
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -395,7 +394,7 @@ public class DataManager {
|
||||
Bukkit.getLogger().severe("Failed to obtain home teleportation location ID");
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
||||
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -433,7 +432,7 @@ public class DataManager {
|
||||
Bukkit.getLogger().severe("Failed to obtain warp teleportation location ID");
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
||||
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -518,7 +517,7 @@ public class DataManager {
|
||||
return null;
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
||||
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -540,7 +539,7 @@ public class DataManager {
|
||||
return false;
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
||||
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -573,7 +572,7 @@ public class DataManager {
|
||||
return false;
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
||||
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -600,7 +599,7 @@ public class DataManager {
|
||||
return false;
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
||||
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -627,7 +626,7 @@ public class DataManager {
|
||||
return null;
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
||||
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package me.william278.huskhomes2.data;
|
||||
|
||||
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.TeleportationPoint;
|
||||
import me.william278.huskhomes2.teleport.points.Warp;
|
||||
@@ -60,7 +58,7 @@ public abstract class Database {
|
||||
}
|
||||
|
||||
} catch (SQLException ex) {
|
||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
||||
plugin.getLogger().log(Level.SEVERE, Error.SQL_CONNECTION_EXECUTE, ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -82,7 +80,7 @@ public abstract class Database {
|
||||
ps.setBoolean(5, home.isPublic());
|
||||
ps.executeUpdate();
|
||||
} 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.executeUpdate();
|
||||
} 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();
|
||||
|
||||
} 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();
|
||||
|
||||
} 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();
|
||||
} 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();
|
||||
} 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();
|
||||
} 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.executeUpdate();
|
||||
} 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.executeUpdate();
|
||||
} 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.executeUpdate();
|
||||
} 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.executeUpdate();
|
||||
} 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();
|
||||
} 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.executeUpdate();
|
||||
} 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.executeUpdate();
|
||||
} 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.executeUpdate();
|
||||
} 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
|
||||
@@ -361,7 +359,7 @@ public abstract class Database {
|
||||
ps.setInt(3, ownerID);
|
||||
ps.executeUpdate();
|
||||
} 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.executeUpdate();
|
||||
} 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();
|
||||
} 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();
|
||||
} 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.executeUpdate();
|
||||
} 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();
|
||||
|
||||
} 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.executeUpdate();
|
||||
} 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.executeUpdate();
|
||||
} 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 java.util.logging.Level;
|
||||
|
||||
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){
|
||||
plugin.getLogger().log(Level.SEVERE, "Couldn't execute MySQL statement: ", ex);
|
||||
}
|
||||
|
||||
public static void close(HuskHomes plugin, Exception 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 {
|
||||
|
||||
final String SQLiteDatabaseName = "HuskHomesData";
|
||||
private final String SQLiteDatabaseName = "HuskHomesData";
|
||||
|
||||
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