mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-03 14:38:53 +00:00
Refactoring, improve database system and add creation timestamp to homes and warps
This commit is contained in:
1 parent
58eeab20c5
commit
98893814f7
24 files changed
+549
-657
No files matched your search
@@ -64,16 +64,7 @@ public class EditHomeCommand extends CommandBase implements TabCompleter {
|
||||
case "description" -> {
|
||||
if (args.length >= 3) {
|
||||
// Get the new description
|
||||
StringBuilder newDescription = new StringBuilder();
|
||||
for (int i = 2; i < args.length; i++) {
|
||||
if (i > 2) {
|
||||
newDescription.append(" ").append(args[i]);
|
||||
} else {
|
||||
newDescription = new StringBuilder(args[i]);
|
||||
}
|
||||
}
|
||||
String newDescriptionString = newDescription.toString();
|
||||
editHomeDescription(p, homeName, newDescriptionString, connection);
|
||||
editHomeDescription(p, homeName, buildDescription(args), connection);
|
||||
} else {
|
||||
MessageManager.sendMessage(p, "error_invalid_syntax", "/edithome <home> description <new description>");
|
||||
}
|
||||
@@ -93,6 +84,18 @@ public class EditHomeCommand extends CommandBase implements TabCompleter {
|
||||
});
|
||||
}
|
||||
|
||||
public static String buildDescription(String[] args) {
|
||||
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]);
|
||||
}
|
||||
}
|
||||
return newDescription.toString();
|
||||
}
|
||||
|
||||
private void editHomeLocation(Player p, String homeName, Connection connection) throws SQLException {
|
||||
Location newLocation = p.getLocation();
|
||||
TeleportationPoint newTeleportLocation = new TeleportationPoint(newLocation, HuskHomes.getSettings().getServerID());
|
||||
|
||||
@@ -59,16 +59,7 @@ public class EditWarpCommand extends CommandBase implements TabCompleter {
|
||||
case "description" -> {
|
||||
if (args.length >= 3) {
|
||||
// Get the new description
|
||||
StringBuilder newDescription = new StringBuilder();
|
||||
for (int i = 2; i < args.length; i++) {
|
||||
if (i > 2) {
|
||||
newDescription.append(" ").append(args[i]);
|
||||
} else {
|
||||
newDescription = new StringBuilder(args[i]);
|
||||
}
|
||||
}
|
||||
String newDescriptionString = newDescription.toString();
|
||||
editWarpDescription(p, warpName, newDescriptionString, connection);
|
||||
editWarpDescription(p, warpName, EditHomeCommand.buildDescription(args), connection);
|
||||
} else {
|
||||
MessageManager.sendMessage(p, "error_invalid_syntax", "/editwarp <warp> description <new description>");
|
||||
}
|
||||
|
||||
@@ -41,12 +41,10 @@ public class HomeCommand extends CommandBase {
|
||||
}
|
||||
} else {
|
||||
List<Home> homes = DataManager.getPlayerHomes(p.getName(), connection);
|
||||
if (homes != null) {
|
||||
if (homes.size() == 1) {
|
||||
// Teleport the player if they only have one home
|
||||
TeleportManager.queueTimedTeleport(p, homes.get(0), connection);
|
||||
return;
|
||||
}
|
||||
if (homes.size() == 1) {
|
||||
// Teleport the player if they only have one home
|
||||
TeleportManager.queueTimedTeleport(p, homes.get(0), connection);
|
||||
return;
|
||||
}
|
||||
HomeListCommand.displayPlayerHomeList(p, 1);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user