Skip to content

Conversation

@Lemvs
Copy link
Contributor

@Lemvs Lemvs commented Oct 12, 2025

Changelog

  • Added the ability to change the default warp category name.
  • Added the ability to change the default view of the warp category icon. (like in warps menu)
  • Added warp categories to the tab completes of the /is setwarp command.
  • Added the ability to display the number of warps in the warp category icon.
  • Blocked the ability to set warp and category names with spaces via signs and the manage menu, as this prevented them from being used in /is warp <warp-name> <warp-category>, /is delwarp <warp-name>, /is setwarp ... <warp-category> and /is admin delwarp <warp-name> commands - if the name contained spaces, these were two different command arguments, so the command was not executed.
  • Fixed the WARP_CATEGORY_NAME_TOO_LONG and WARP_NAME_TOO_LONG messages because they did not contain &7 after the prefix.
  • Modified the default menu configurations to accommodate these changes.

Copy link
Member

@OmerBenGera OmerBenGera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There can be warps and warp categories with invalid names in the DB, as you could create warps and warp categories with spaces in them
You should check that when loading the warps and warp categories from DB and fix their names - if there are two categories or warps with the same name, then just combine them.

@Lemvs
Copy link
Contributor Author

Lemvs commented Oct 14, 2025

There can be warps and warp categories with invalid names in the DB, as you could create warps and warp categories with spaces in them

You should check that when loading the warps and warp categories from DB and fix their names - if there are two categories or warps with the same name, then just combine them.

How do you propose to do it? In which file? And in what sense to combine them?

@OmerBenGera
Copy link
Member

There can be warps and warp categories with invalid names in the DB, as you could create warps and warp categories with spaces in them
You should check that when loading the warps and warp categories from DB and fix their names - if there are two categories or warps with the same name, then just combine them.

How do you propose to do it? In which file? And in what sense to combine them?

https://github.com/BG-Software-LLC/SuperiorSkyblock2/blob/dev/src/main/java/com/bgsoftware/superiorskyblock/core/database/serialization/IslandsDeserializer.java#L239
https://github.com/BG-Software-LLC/SuperiorSkyblock2/blob/dev/src/main/java/com/bgsoftware/superiorskyblock/core/database/serialization/IslandsDeserializer.java#L658

@Lemvs
Copy link
Contributor Author

Lemvs commented Oct 14, 2025

There can be warps and warp categories with invalid names in the DB, as you could create warps and warp categories with spaces in them
You should check that when loading the warps and warp categories from DB and fix their names - if there are two categories or warps with the same name, then just combine them.

How do you propose to do it? In which file? And in what sense to combine them?

https://github.com/BG-Software-LLC/SuperiorSkyblock2/blob/dev/src/main/java/com/bgsoftware/superiorskyblock/core/database/serialization/IslandsDeserializer.java#L239 https://github.com/BG-Software-LLC/SuperiorSkyblock2/blob/dev/src/main/java/com/bgsoftware/superiorskyblock/core/database/serialization/IslandsDeserializer.java#L658

Hmm, okay, but how do I combine them? I see that when the name is for example too long, it's just shortened.

@Lemvs
Copy link
Contributor Author

Lemvs commented Oct 14, 2025

@OmerBenGera what do you think?

  • I moved these methods to IslandNames, and also used them in IslandSigns (so I removed some Reasons there because they weren't really useful anyway) and in CmdSetWarp.
  • I removed the WARP_RENAME_ALREADY_EXIST message because there's a very similar WARP_ALREADY_EXIST message, and changed the WARP_CATEGORY_RENAME_ALREAY_EXIST message to WARP_CATEGORY_ALREADY_EXIST to keep these names consistent (for now, I've only changed it in en-US because I want to know what you think).
  • I haven't checked yet \n because I can't do it now, I'll look at it later
  • Wouldn't it be better to combine ..._ILLEGAL_NAME and ..._INVALID_NAME into one message? Both spaces and empty names are not allowed, so why two messages?

@OmerBenGera
Copy link
Member

@OmerBenGera what do you think?

  • I moved these methods to IslandNames, and also used them in IslandSigns (so I removed some Reasons there because they weren't really useful anyway) and in CmdSetWarp.
  • I removed the WARP_RENAME_ALREADY_EXIST message because there's a very similar WARP_ALREADY_EXIST message, and changed the WARP_CATEGORY_RENAME_ALREAY_EXIST message to WARP_CATEGORY_ALREADY_EXIST to keep these names consistent (for now, I've only changed it in en-US because I want to know what you think).
  • I haven't checked yet \n because I can't do it now, I'll look at it later
  • Wouldn't it be better to combine ..._ILLEGAL_NAME and ..._INVALID_NAME into one message? Both spaces and empty names are not allowed, so why two messages?
  1. Great
  2. Great, you can change it in all lang files
  3. Do it and update the code. Do it for all the weird chars (\n, \r, \t, whitespaces, etc)
  4. Yeah, you can do it.

Copy link
Member

@OmerBenGera OmerBenGera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check for whitespaces, \n, \r, \t, etc.

@Lemvs
Copy link
Contributor Author

Lemvs commented Oct 17, 2025

Check for whitespaces, \n, \r, \t, etc.

There are no problems with these characters, they can be used normally in commands, only spaces cause problems:
image
image

@Lemvs
Copy link
Contributor Author

Lemvs commented Oct 17, 2025

There can be warps and warp categories with invalid names in the DB, as you could create warps and warp categories with spaces in them
You should check that when loading the warps and warp categories from DB and fix their names - if there are two categories or warps with the same name, then just combine them.

How do you propose to do it? In which file? And in what sense to combine them?

https://github.com/BG-Software-LLC/SuperiorSkyblock2/blob/dev/src/main/java/com/bgsoftware/superiorskyblock/core/database/serialization/IslandsDeserializer.java#L239 https://github.com/BG-Software-LLC/SuperiorSkyblock2/blob/dev/src/main/java/com/bgsoftware/superiorskyblock/core/database/serialization/IslandsDeserializer.java#L658

Hmm, okay, but how do I combine them? I see that when the name is for example too long, it's just shortened.

@OmerBenGera and you can tell me what to do with it because I have no idea :/

@OmerBenGera
Copy link
Member

There can be warps and warp categories with invalid names in the DB, as you could create warps and warp categories with spaces in them
You should check that when loading the warps and warp categories from DB and fix their names - if there are two categories or warps with the same name, then just combine them.

How do you propose to do it? In which file? And in what sense to combine them?

https://github.com/BG-Software-LLC/SuperiorSkyblock2/blob/dev/src/main/java/com/bgsoftware/superiorskyblock/core/database/serialization/IslandsDeserializer.java#L239 https://github.com/BG-Software-LLC/SuperiorSkyblock2/blob/dev/src/main/java/com/bgsoftware/superiorskyblock/core/database/serialization/IslandsDeserializer.java#L658

Hmm, okay, but how do I combine them? I see that when the name is for example too long, it's just shortened.

@OmerBenGera and you can tell me what to do with it because I have no idea :/

Split spaces and take the first word. If it's a category and it already exists, you can just add all the warps to the existing category. If that's a warp that already exists, just earn in console and do not load that warp

@OmerBenGera
Copy link
Member

Check for whitespaces, \n, \r, \t, etc.

There are no problems with these characters, they can be used normally in commands, only spaces cause problems: image image

But if you use an actual tab, does it work?

@Lemvs
Copy link
Contributor Author

Lemvs commented Oct 18, 2025

Split spaces and take the first word. If it's a category and it already exists, you can just add all the warps to the existing category. If that's a warp that already exists, just earn in console and do not load that warp

@OmerBenGera can you help me with this? I've been trying to do something, but I have no idea how to use this file. I wanted to do something like this, but I can't get the island because they're loaded at the very end in the DataManager. Builder has get... methods, but no getWarps, so I have no idea how to check it.

public static void deserializeWarps(DatabaseBridge databaseBridge, DatabaseCache<Island.Builder> databaseCache) {
        databaseBridge.loadAllObjects("islands_warps", islandWarpsRow -> {
            DatabaseResult islandWarp = new DatabaseResult(islandWarpsRow);

            Optional<UUID> uuid = islandWarp.getUUID("island");
            if (!uuid.isPresent()) {
                Log.warn("Cannot load warps for null islands, skipping...");
                return;
            }

            Optional<String> name = islandWarp.getString("name").map(_name -> IslandNames.isWarpNameLengthValid(_name) ?
                    _name : _name.substring(0, IslandNames.getMaxWarpNameLength()));

            if (!name.isPresent() || name.get().isEmpty()) {
                Log.warn("Cannot load warps with invalid names for ", uuid.get(), ", skipping...");
                return;
            }

            String splitName = name.get().split(" ")[0];

            if (!name.get().equals(splitName)) {
                Island island = plugin.getGrid().getIsland(uuid.get());

                if (island.getWarp(splitName) != null) {
                    Log.warn("Cannot load warp with same name for ", uuid.get(), ", skipping...");
                    return;
                } else {
                    name = Optional.of(splitName);
                }
            }

            Optional<Location> location = islandWarp.getString("location").map(Serializers.LOCATION_SERIALIZER::deserialize);
            if (!location.isPresent()) {
                Log.warn("Cannot load warps with invalid locations for ", uuid.get(), ", skipping...");
                return;
            }

            Island.Builder builder = databaseCache.computeIfAbsentInfo(uuid.get(), IslandBuilderImpl::new);
            builder.addWarp(name.get(), islandWarp.getString("category").orElse(""),
                    location.get(), islandWarp.getBoolean("private").orElse(!plugin.getSettings().isPublicWarps()),
                    islandWarp.getString("icon").map(Serializers.ITEM_STACK_SERIALIZER::deserialize).orElse(null));
        });
    }

@Lemvs
Copy link
Contributor Author

Lemvs commented Oct 18, 2025

But if you use an actual tab, does it work?

I don't understand what you mean :/
If you mean something like this, it can't be pasted in chat and it disappears on the sign https://unicode-explorer.com/c/0009

@Lemvs
Copy link
Contributor Author

Lemvs commented Oct 18, 2025

I came up with something like this, it works, but I don't know if I should do it this way

     public static void deserializeWarps(DatabaseBridge databaseBridge, DatabaseCache<Island.Builder> databaseCache) {
        Map<UUID, Set<String>> warpNames = new HashMap<>();
        databaseBridge.loadAllObjects("islands_warps", islandWarpsRow -> {
            DatabaseResult islandWarp = new DatabaseResult(islandWarpsRow);

            Optional<UUID> uuid = islandWarp.getUUID("island");
            if (!uuid.isPresent()) {
                Log.warn("Cannot load warps for null islands, skipping...");
                return;
            }

            Optional<String> name = islandWarp.getString("name").map(_name -> {
                String splitName = _name.split(" ")[0];
                return IslandNames.isWarpNameLengthValid(splitName) ? splitName : splitName.substring(0, IslandNames.getMaxWarpNameLength());
            });

            if (!name.isPresent() || name.get().isEmpty()) {
                Log.warn("Cannot load warps with invalid names for ", uuid.get(), ", skipping...");
                return;
            }

            warpNames.computeIfAbsent(uuid.get(), u -> new HashSet<>());
            if (warpNames.get(uuid.get()).contains(name.get())) {
                Log.warn("Cannot load warps with same name for ", uuid.get(), ", skipping...");
                return;
            }
            warpNames.get(uuid.get()).add(name.get());

            Optional<Location> location = islandWarp.getString("location").map(Serializers.LOCATION_SERIALIZER::deserialize);
            if (!location.isPresent()) {
                Log.warn("Cannot load warps with invalid locations for ", uuid.get(), ", skipping...");
                return;
            }

            Island.Builder builder = databaseCache.computeIfAbsentInfo(uuid.get(), IslandBuilderImpl::new);
            builder.addWarp(name.get(), islandWarp.getString("category").orElse(""),
                    location.get(), islandWarp.getBoolean("private").orElse(!plugin.getSettings().isPublicWarps()),
                    islandWarp.getString("icon").map(Serializers.ITEM_STACK_SERIALIZER::deserialize).orElse(null));
        });
    }

@OmerBenGera
Copy link
Member

OmerBenGera commented Oct 18, 2025

I came up with something like this, it works, but I don't know if I should do it this way

     public static void deserializeWarps(DatabaseBridge databaseBridge, DatabaseCache<Island.Builder> databaseCache) {
        Map<UUID, Set<String>> warpNames = new HashMap<>();
        databaseBridge.loadAllObjects("islands_warps", islandWarpsRow -> {
            DatabaseResult islandWarp = new DatabaseResult(islandWarpsRow);

            Optional<UUID> uuid = islandWarp.getUUID("island");
            if (!uuid.isPresent()) {
                Log.warn("Cannot load warps for null islands, skipping...");
                return;
            }

            Optional<String> name = islandWarp.getString("name").map(_name -> {
                String splitName = _name.split(" ")[0];
                return IslandNames.isWarpNameLengthValid(splitName) ? splitName : splitName.substring(0, IslandNames.getMaxWarpNameLength());
            });

            if (!name.isPresent() || name.get().isEmpty()) {
                Log.warn("Cannot load warps with invalid names for ", uuid.get(), ", skipping...");
                return;
            }

            warpNames.computeIfAbsent(uuid.get(), u -> new HashSet<>());
            if (warpNames.get(uuid.get()).contains(name.get())) {
                Log.warn("Cannot load warps with same name for ", uuid.get(), ", skipping...");
                return;
            }
            warpNames.get(uuid.get()).add(name.get());

            Optional<Location> location = islandWarp.getString("location").map(Serializers.LOCATION_SERIALIZER::deserialize);
            if (!location.isPresent()) {
                Log.warn("Cannot load warps with invalid locations for ", uuid.get(), ", skipping...");
                return;
            }

            Island.Builder builder = databaseCache.computeIfAbsentInfo(uuid.get(), IslandBuilderImpl::new);
            builder.addWarp(name.get(), islandWarp.getString("category").orElse(""),
                    location.get(), islandWarp.getBoolean("private").orElse(!plugin.getSettings().isPublicWarps()),
                    islandWarp.getString("icon").map(Serializers.ITEM_STACK_SERIALIZER::deserialize).orElse(null));
        });
    }
  1. You can't access Islands at this stage yet, so you did good for removing GridManager#getIsland.
  2. You can use Builder#hasWarp and Builder#hasWarpCategory to check if the warp or warp category already exists
    Remove the warpNames map, use these methods instead

@Lemvs
Copy link
Contributor Author

Lemvs commented Oct 18, 2025

^ @OmerBenGera like this? I had the following warps, created on the latest dev build:
image
image

And after uploading my version, I had one 'Default' category (there are two in the screenshot, but I created 'test' later to show that there is only one 'Default'), with warp 'default1' and 'default2' in it:
image
image
image
image

And while loading the server, I got these warnings (one by double default2 warp, the second by double Default category):

[19:18:25] [Server thread/WARN]: [SuperiorSkyblock2] Cannot load warps with same name for 7add9896-3975-4ff3-b822-bad62b3db790, skipping...
[19:18:25] [Server thread/WARN]: [SuperiorSkyblock2] Cannot load warp categories with same name for 7add9896-3975-4ff3-b822-bad62b3db790, skipping...

@Lemvs
Copy link
Contributor Author

Lemvs commented Oct 27, 2025

@OmerBenGera so, is it okay or does something need to be changed?

@Lemvs
Copy link
Contributor Author

Lemvs commented Dec 23, 2025

@OmerBenGera when will you be able to see it, because I have planned big changes in the warps and visitors signs, because they have different issues and the visitor signs are very poorly made, they lack various functions, but I can't continue without these changes and I don't want to do everything in one project 😓😓😓

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants