Initial Gui support(hard coded English for the time being)#458
Initial Gui support(hard coded English for the time being)#458jerzean wants to merge 1 commit intoespidev:masterfrom
Conversation
still may be a bug or 3
|
top |
|
Can you add holograms above the blocks? |
| depend: [WorldGuard, WorldEdit] | ||
| softdepend: [Vault, PlaceholderAPI, LuckPerms] | ||
| main: dev.espi.protectionstones.ProtectionStones | ||
| api-version: 1.21.10 |
There was a problem hiding this comment.
Probably unintended, we shouldn't lower the api-version
| "protectionstones" | ||
| ] | ||
|
|
||
|
|
| # "blacklist" mode prevents this protect block from being used in the worlds in "worlds" | ||
| # "whitelist" mode allows this protect block to only be used in the worlds in "worlds" | ||
| # Can be overridden with protectionstones.admin permission (including OP)! | ||
| # Can be overriden with protectionstones.admin permission (including OP)! |
There was a problem hiding this comment.
It should be "overridden", not overriden
| public class ProtectionStones extends JavaPlugin { | ||
| // change this when the config version goes up | ||
| public static final int CONFIG_VERSION = 16; | ||
| public static final int CONFIG_VERSION = 19; |
There was a problem hiding this comment.
Any reason why we are bumping versions from 16 -> 19? We can just bump to 17
| ProtectionStones.config.set("gui.commands.tp", true); | ||
| ProtectionStones.config.set("gui.commands.unclaim", true); | ||
| ProtectionStones.config.set("gui.commands.priority", true); | ||
| ProtectionStones.config.setComment("gui.commands", " Per-command GUI toggles (only used if gui.enabled = true).\n Supported: home, flag, add, remove, addowner, removeowner, list, info, tp, unclaim, priority"); |
There was a problem hiding this comment.
Any reason why we're setting the same comment 3 times?
| * Unclaims a region (returns protection stone items if configured, then deletes the region). | ||
| * This mirrors the behavior in ArgUnclaim. | ||
| */ | ||
| public static boolean unclaimRegion(PSRegion r, Player p) { |
There was a problem hiding this comment.
Can we share the same implementation with /ps unclaim?
| if (mode == Mode.REMOVE_OWNER) { | ||
| if (target.equals(viewer.getUniqueId()) && region.getOwners().size() <= 1) { | ||
| PSL.msg(viewer, PSL.CANNOT_REMOVE_YOURSELF_LAST_OWNER.msg()); | ||
| return; | ||
| } | ||
| } | ||
|
|
||
| // Apply (async like original command implementation) | ||
| Bukkit.getScheduler().runTaskAsynchronously(ProtectionStones.getInstance(), () -> { | ||
| String name = safeName(target); | ||
|
|
||
| switch (mode) { | ||
| case ADD_MEMBER -> { | ||
| if (region.isMember(target) || region.isOwner(target)) { | ||
| PSL.msg(viewer, "&e" + name + " &7is already added."); | ||
| return; | ||
| } | ||
| region.addMember(target); | ||
| PSL.msg(viewer, PSL.ADDED_TO_REGION.msg().replace("%player%", name)); | ||
| Bukkit.getScheduler().runTaskAsynchronously(ProtectionStones.getInstance(), () -> UUIDCache.storeWGProfile(target, name)); | ||
| } | ||
| case REMOVE_MEMBER -> { | ||
| if (!region.isMember(target)) { | ||
| PSL.msg(viewer, "&e" + name + " &7is not a member."); | ||
| return; | ||
| } | ||
| region.removeMember(target); | ||
| PSL.msg(viewer, PSL.REMOVED_FROM_REGION.msg().replace("%player%", name)); | ||
| } | ||
| case ADD_OWNER -> { | ||
| if (region.isOwner(target)) { | ||
| PSL.msg(viewer, "&e" + name + " &7is already an owner."); | ||
| return; | ||
| } | ||
| // limit checks (reuse existing logic) | ||
| ArgAddRemove helper = new ArgAddRemove(); | ||
| if (helper.determinePlayerSurpassedLimit(viewer, Collections.singletonList(region), PSPlayer.fromUUID(target))) { | ||
| return; | ||
| } | ||
| region.addOwner(target); | ||
| PSL.msg(viewer, PSL.ADDED_TO_REGION.msg().replace("%player%", name)); | ||
| Bukkit.getScheduler().runTaskAsynchronously(ProtectionStones.getInstance(), () -> UUIDCache.storeWGProfile(target, name)); | ||
| } | ||
| case REMOVE_OWNER -> { | ||
| if (!region.isOwner(target)) { | ||
| PSL.msg(viewer, "&e" + name + " &7is not an owner."); | ||
| return; | ||
| } | ||
| region.removeOwner(target); | ||
| PSL.msg(viewer, PSL.REMOVED_FROM_REGION.msg().replace("%player%", name)); | ||
| } | ||
| } |
There was a problem hiding this comment.
Is there any way we could use the same implementation as /ps add/remove/addowner/removeowner, with an extracted helper function?
| import java.util.function.Supplier; | ||
|
|
||
| /** Inventory menu for /ps admin. Executes selected actions after confirmation. */ | ||
| public class AdminMenuGui extends BaseGui { |
There was a problem hiding this comment.
To be honest, I'm a bit unsure of whether we should have a /ps admin GUI at all, they are supposed to be for server administators and some of the commands are quite destructive, so I wouldn't make it too easy to use
| String tx = ChatColor.AQUA + "> " + ChatColor.GRAY + bc; | ||
| String baseCommand = ProtectionStones.getInstance().getConfigOptions().base_command; | ||
| String bc = "/" + baseCommand; | ||
| String tx = ChatColor.AQUA + "> " + ChatColor.GRAY + "/" + bc; |
There was a problem hiding this comment.
Isn't this going to cause double slashes?
| tx + " admin version", | ||
| "Show the version number of the plugin.\n\n" + bc + " admin version", | ||
| bc + " admin version", | ||
| baseCommand + " admin version", |
There was a problem hiding this comment.
Isn't this going to now miss a slash?
still may be a bug or 3
Please look this over and let me know if you see anything obvious