Add "minecraft.spectatetp".#1729
Conversation
This comment was marked as spam.
This comment was marked as spam.
|
Please add a configuration option that would enable the requirement of this permission. We avoid making any changes that would automatically change any behavior from Paper. |
|
I'll update the code. Does "spectator-teleport-permission" sound like an appropriate name for the configuration setting? |
|
"require-spectator-teleport-permission" sounds better to understand in my opinion |
This is what I would go with as well. |
|
I've added a configuration entry for the permission node. It is set to "false" by default. Are any other changes needed? I apologise for the delay as well. I have a lot going on in real life. |
|
I'm going to update the patches to make them work with Java Edition 26.2. This might take a bit. |
…leport-node.patch
…n-entry-for-spectatetp-permission.patch
…ectatetp-setting.patch
granny
left a comment
There was a problem hiding this comment.
Not a bad idea, just some requested changes.
If you register the permission in the PurpurPermissions class in the registerPermissions() method as default true, you can avoid needing to specify a config option for this permission.
Please include a PR to PurpurDocs in the permissions page, and for the config option if we decide to keep it.
| - if (this.player.isSpectator()) { | ||
| - for (ServerLevel level : this.server.getAllLevels()) { | ||
| - Entity entity = packet.getEntity(level); | ||
| - if (entity != null) { | ||
| - this.player.teleportTo(level, entity.getX(), entity.getY(), entity.getZ(), Set.of(), entity.getYRot(), entity.getXRot(), true, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.SPECTATE); // CraftBukkit | ||
| - return; | ||
| + if (org.purpurmc.purpur.PurpurConfig.requireSpectatorTeleportPermission) { | ||
| + if (this.player.isSpectator() && this.player.getBukkitEntity().hasPermission("minecraft.spectatetp")) { | ||
| + for (ServerLevel level : this.server.getAllLevels()) { | ||
| + Entity entity = packet.getEntity(level); | ||
| + if (entity != null) { | ||
| + this.player.teleportTo(level, entity.getX(), entity.getY(), entity.getZ(), Set.of(), entity.getYRot(), entity.getXRot(), true, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.SPECTATE); // CraftBukkit | ||
| + return; | ||
| + } | ||
| + } | ||
| + } | ||
| + } else { | ||
| + if (this.player.isSpectator()) { | ||
| + for (ServerLevel level : this.server.getAllLevels()) { | ||
| + Entity entity = packet.getEntity(level); | ||
| + if (entity != null) { | ||
| + this.player.teleportTo(level, entity.getX(), entity.getY(), entity.getZ(), Set.of(), entity.getYRot(), entity.getXRot(), true, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.SPECTATE); // CraftBukkit | ||
| + return; | ||
| + } |
There was a problem hiding this comment.
This is a pretty noisy diff for what it adds. Please reduce it to a maintainable level.
| - this.player.teleportTo(level, entity.getX(), entity.getY(), entity.getZ(), Set.of(), entity.getYRot(), entity.getXRot(), true, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.SPECTATE); // CraftBukkit | ||
| - return; | ||
| + if (org.purpurmc.purpur.PurpurConfig.requireSpectatorTeleportPermission) { | ||
| + if (this.player.isSpectator() && this.player.getBukkitEntity().hasPermission("minecraft.spectatetp")) { |
There was a problem hiding this comment.
I don't like the permission name and i'm not sure about putting it under the "minecraft" perm root. Maybe purpur.spectator-can-teleport-to-players? Open to suggestions other than minecraft.spectatetp.
| org.purpurmc.purpur.PurpurConfig.clampEnchantLevels = purpurConfiguration.getBoolean("settings.enchantment.clamp-levels", true); | ||
| org.purpurmc.purpur.PurpurConfig.registerMinecraftDebugCommands = purpurConfiguration.getBoolean("settings.register-minecraft-debug-commands"); // Purpur - register minecraft debug commands | ||
| org.purpurmc.purpur.PurpurConfig.registerMinecraftDisabledCommands = purpurConfiguration.getBoolean("settings.register-minecraft-disabled-commands"); // Purpur - register disabled minecraft commands | ||
| + org.purpurmc.purpur.PurpurConfig.requireSpectatorTeleportPermission = purpurConfiguration.getBoolean("settings.require-spectator-teleport-permission"); // Purpur - require spectator teleport permission |
There was a problem hiding this comment.
settings.require-permission-spectator-teleport-to-players? 🤷
|
I updated the code. Before I submit a pull request to the PurpurDocs repository, I'd like to ask if this is what you're looking for? |
pretty sure granny meant to modify the existing patch instead of adding another one on top of it that "makes code less noisy" |
|
Yeah those patches are really wrong. You should update the current patch you did, the 0022- patch and make it less noisy (simpler and shorter) |
|
Is this better? |
| + // Purpur end - Add settings for enabling commands that are unavailable by default. | ||
| + | ||
| + // Purpur start - Add setting which can be used to enable a permission node that controls the ability for spectators to teleport to other players. | ||
| + org.purpurmc.purpur.PurpurConfig.requirePermissionSpectatorTeleportToPlayers = purpurConfiguration.getBoolean("settings.require-permission-spectator-teleport-to-players"); // Purpur - require permission spectator teleport to players |
There was a problem hiding this comment.
You should comment here with // Purpur instead of having // Purpur start and // Purpur end
| - if (entity != null) { | ||
| - this.player.teleportTo(level, entity.getX(), entity.getY(), entity.getZ(), Set.of(), entity.getYRot(), entity.getXRot(), true, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.SPECTATE); // CraftBukkit | ||
| - return; | ||
| + if (!org.purpurmc.purpur.PurpurConfig.requirePermissionSpectatorTeleportToPlayers || this.player.getBukkitEntity().hasPermission("purpur.spectator-can-teleport-to-players")) { |
There was a problem hiding this comment.
Add a // Purpur comment
|
The comments are updated now. |
I would like to suggest the addition of a "minecraft.spectatetp" permission node. It would allow for control over whether or not people can teleport to others in Spectator mode.
This idea originates from BasicLandMC: https://github.com/Basic-Land/BasicLandMC/blob/6936acca0bd195f762e9c09e8899d382eacd0c12/basiclandmc-server/minecraft-patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch