SuperiorSkyblock Integration#446
Conversation
| ObjectFetcher.registerWithObjectFetcher(SuperiorSkyblockIslandTag.class, SuperiorSkyblockIslandTag.tagProcessor); | ||
|
|
||
| // <--[tag] | ||
| // @attribute <island[<name>]> |
|
|
||
| // <--[ObjectType] | ||
| // @name SuperiorSkyblockIslandTag | ||
| // @prefix island |
There was a problem hiding this comment.
should include the plugin name on the prefix here
| public static void register() { | ||
|
|
||
| // <--[tag] | ||
| // @attribute <PlayerTag.bypass_mode> |
There was a problem hiding this comment.
these tags should be prefixed
| // Returns whether a player can build on islands that they are not a part of. | ||
| // --> | ||
| PlayerTag.tagProcessor.registerTag(ElementTag.class, "superiorskyblock_bypass_mode", (attribute, player) -> { | ||
| return new ElementTag(SuperiorSkyblockAPI.getPlayer(player.getUUID()).hasBypassModeEnabled()); |
There was a problem hiding this comment.
could probably make a helper method for SuperiorSkyblockAPI.getPlayer(player.getUUID())? it is repeated quite a bit
| // <SuperiorSkyblockIslandTag.name> | ||
| // --> | ||
| tagProcessor.registerMechanism("name", false, ElementTag.class, (object, mechanism, value) -> { | ||
| if (!mechanism.getValue().asString().isEmpty() && SuperiorSkyblockAPI.getIsland(mechanism.getValue().asString()) != null) { |
There was a problem hiding this comment.
is this if check correct? it looks like you're checking whether the island with this name exists
There was a problem hiding this comment.
it's a way of preventing two islands from having the same name, since that's their unique identifier in the SuperiorSkyblockIslandTag.
There was a problem hiding this comment.
yes but youre checking if the island with the given name is not null therefore if it exists
// I think that what do you want to do is check if the island with given name is null
| // --> | ||
| tagProcessor.registerMechanism("balance", false, ElementTag.class, (object, mechanism, value) -> { | ||
| if (mechanism.requireDouble()) { | ||
| object.getIsland().getIslandBank().setBalance(mechanism.getValue().asBigDecimal()); |
There was a problem hiding this comment.
use value not mechanism.getValue()
| // <SuperiorSkyblockIslandTag.size> | ||
| // --> | ||
| tagProcessor.registerMechanism("size", false, ElementTag.class, (object, mechanism, value) -> { | ||
| if (mechanism.requireInteger() && mechanism.getValue().asInt() >= 1) { |
There was a problem hiding this comment.
this >= 1 check needs its own else with an echoError (so it doesn't just silently ignore incorrect inputs). Also doc the range limit in the meta
| // <SuperiorSkyblockIslandTag.name> | ||
| // --> | ||
| tagProcessor.registerMechanism("name", false, ElementTag.class, (object, mechanism, value) -> { | ||
| if (!mechanism.getValue().asString().isEmpty() && SuperiorSkyblockAPI.getIsland(mechanism.getValue().asString()) == null) { |
There was a problem hiding this comment.
needs an else echoError. Also document what the expected limitations are in the meta
- mechanism.echoError additions
| // <SuperiorSkyblockIslandTag.name> | ||
| // --> | ||
| tagProcessor.registerMechanism("name", false, ElementTag.class, (object, mechanism, value) -> { | ||
| if (!mechanism.getValue().asString().isEmpty()) { |
There was a problem hiding this comment.
this check is free-floating - should have an error message
| // @returns SuperiorSkyblockIslandTag | ||
| // @plugin Depenizen, SuperiorSkyblock | ||
| // @description | ||
| // Returns the superiorskyblock island tag with the given name. |
There was a problem hiding this comment.
Add an object link, // Refer to <@link objecttype SuperiorSkyblockIslandTag>. on a newline is what most object constructor tags have
| this.<SuperiorSkyblockIslandCreatedScriptEvent, ElementTag>registerDetermination("name", ElementTag.class, (evt, context, name) -> { | ||
| evt.event.getIsland().setName(name.asString()); | ||
| }); |
There was a problem hiding this comment.
Having utility determinations is nice, but I'd probably prioritize the event's actual options - e.g. looking at the JD it seems to let you control whether the player will automatically teleport to their Island & get what schematic the island was created from.
| // @prefix superiorskyblock_island | ||
| // @base ElementTag | ||
| // @format | ||
| // The identity format for group is <island_name> |
| if (island == null) { | ||
| return null; | ||
| } |
There was a problem hiding this comment.
This should probably have some error message? otherwise you'd have no idea what's going wrong if you provide an invalid name.
| public static boolean matches(String string) { | ||
| string = string.replace("superiorskyblock_island@", ""); | ||
| return SuperiorSkyblockAPI.getIsland(string) != null; | ||
| } |
There was a problem hiding this comment.
Having the prefix is usually treated as a pass, see e.g. WorldGuardRegionTag.
| // Returns the description of the specified island, if any. | ||
| // --> | ||
| tagProcessor.registerTag(ElementTag.class, "description", (attribute, object) -> { | ||
| return object.getIsland().getDescription().isBlank() ? null : new ElementTag(object.getIsland().getDescription(), true); |
There was a problem hiding this comment.
A. any specific reason for #isBlank over #isEmpty?
B. Are we sure this should be nullable as opposed to matching what the plugin does and returning an empty element?
| // <SuperiorSkyblockIslandTag.name> | ||
| // --> | ||
| tagProcessor.registerMechanism("name", false, ElementTag.class, (object, mechanism, value) -> { | ||
| if (mechanism.getValue().asString().isEmpty()) { |
| mechanism.echoError("You cannot have an island with no name."); | ||
| } | ||
| else if (SuperiorSkyblockAPI.getIsland(value.asString()) != null) { | ||
| mechanism.echoError("There is already an island with the name '" + value.asString() + "'."); |
There was a problem hiding this comment.
Nitpick, but no need for #asString here (Java automatically calls #toString on objects when concatenating them with strings)
| if (string.startsWith("superiorskyblock_island@")) { | ||
| string = string.substring("superiorskyblock_island@".length()); | ||
| } | ||
| Island island = SuperiorSkyblockAPI.getIsland(string); |
There was a problem hiding this comment.
Islands seem to have both UUIDs and names, probably better to have the objects identify based on the UUIDs rather than names, as the names are changeable.
| // @input ElementTag(Boolean) | ||
| // @plugin Depenizen, SuperiorSkyblock | ||
| // @description | ||
| // Changes whether a player can build on islands that are not a part of. |
There was a problem hiding this comment.
islands that are not a part of
they*
| // @returns ElementTag | ||
| // @plugin Depenizen, SuperiorSkyblock | ||
| // @description | ||
| // Returns the description of this island, if any. |
There was a problem hiding this comment.
What does , if any mean here?
Aya previously asked B. Are we sure this should be nullable as opposed to matching what the plugin does and returning an empty element? and you didn't reply but just went and removed the null without changing the meta.
Reminder ftr that PR comment aren't commands, you're welcome to have answered "Yes null is better" if you had reason to think so.
…landtag, slight meta clarification
| // --> | ||
| tagProcessor.registerTag(ElementTag.class, "balance", (attribute, object) -> { | ||
| if (object.getIsland().isSpawn()) { | ||
| Debug.echoError("Spawn islands cannot have a balance."); |
| if (string.startsWith("superiorskyblock_island@")) { | ||
| string = string.substring("superiorskyblock_island@".length()); | ||
| } | ||
| Island island = string.equals("00000000-0000-0000-0000-000000000000") ? SuperiorSkyblockAPI.getSpawnIsland() : SuperiorSkyblockAPI.getIslandByUUID(UUID.fromString(string)); |
There was a problem hiding this comment.
Can use CoreUtilities#tryParseUUID & null check it (and maybe an error message).
Also for this 00 UUID - is that the island's actual UUID? if not it will likely have problems in identify & persisting the object.
| } | ||
| Island island = string.equals("00000000-0000-0000-0000-000000000000") ? SuperiorSkyblockAPI.getSpawnIsland() : SuperiorSkyblockAPI.getIslandByUUID(UUID.fromString(string)); | ||
| if (island == null) { | ||
| Debug.echoError("No island with the uuid '" + string + "' exists."); |
There was a problem hiding this comment.
Should check the context for the error message, context == null || context.showErrors() - can see existing valueOf methods for examples.
| // @returns ListTag(PlayerTag) | ||
| // @plugin Depenizen, SuperiorSkyblock | ||
| // @description | ||
| // Returns the members of this island, including the leader. |
There was a problem hiding this comment.
Nitpick, but probably best to match the rest of the meta here (leader -> owner), assuming it's the same value
| // Returns the current average rating of an island. | ||
| // --> | ||
| tagProcessor.registerTag(ElementTag.class, "total_rating", (attribute, object) -> { |
There was a problem hiding this comment.
If this is the average rating it'd probably make sense to name the tag after that?
...a/com/denizenscript/depenizen/bukkit/objects/superiorskyblock/SuperiorSkyblockIslandTag.java
Show resolved
Hide resolved
| } | ||
| try { | ||
| UUID uuid = UUID.fromString(string); | ||
| UUID spawnUUID = UUID.fromString("00000000-0000-0000-0000-000000000000"); |
There was a problem hiding this comment.
Should put the UUID in a public static final, this will parse it every time.
| public SuperiorSkyblockPlayerExtensions(PlayerTag player) { | ||
| this.player = player; | ||
| } | ||
|
|
||
| PlayerTag player; |

Requested in https://discord.com/channels/315163488085475337/1117046369434218517 and https://discord.com/channels/315163488085475337/1237853546070675527
Resolves #411