Skip to content

Commit

Permalink
Show the current beacon color in the GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
Sytm committed May 20, 2024
1 parent a008ea8 commit 33d773d
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- When using `/waypoints other <...>` to inspect another players waypoints, the waypoints can now be modified and removed when the player has the permission `waypoints.modify.other`
- Disable plugin remapping on 1.20.6+ servers because this plugin does not utilize NMS
- Each page in the GUI has now a different title, instead if it being a single static one
- On the waypoint page in the GUI the current beacon color is now shown

### Fixed
- When having public ownership enabled, the owner is also displayed at the bottom of the waypoint and folder description for private ones
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,9 @@ internal class BeaconPointer(
if (create) {
player.sendBlockChange(
loc,
(if (trackable is StaticTrackable) {
trackable.beaconColor
} else {
null
} ?: config.getDefaultColor(trackable) ?: BeaconColor.CLEAR)
((trackable as? StaticTrackable)?.beaconColor
?: config.getDefaultColor(trackable)
?: BeaconColor.CLEAR)
.blockData)
} else {
player.sendActualBlock(loc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class BeaconConfigurationImpl : RepeatingPointerConfigurationImpl(), BeaconConfi
else -> null
}

fun getDefaultColor(type: Type) = defaultColor[type]

@UseAdapter(BeaconColorDefaults::class)
private var defaultColor: Map<Type, BeaconColor> = emptyMap()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import de.md5lukas.kinvs.items.GUIContent
import de.md5lukas.kinvs.items.GUIItem
import de.md5lukas.waypoints.api.Waypoint
import de.md5lukas.waypoints.gui.WaypointsGUI
import de.md5lukas.waypoints.pointers.BeaconColor
import net.kyori.adventure.text.Component
import org.bukkit.inventory.ItemStack

Expand Down Expand Up @@ -44,6 +43,7 @@ class SelectBeaconColorPage(wpGUI: WaypointsGUI, private val waypoint: Waypoint)
switchContext(SynchronizationContext.SYNC)
wpGUI.playSound { clickSuccess }
wpGUI.goBack()
(wpGUI.gui.activePage as BasePage).update()
}
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import de.md5lukas.waypoints.gui.WaypointsGUI
import de.md5lukas.waypoints.integrations.DynMapIntegration
import de.md5lukas.waypoints.integrations.Pl3xMapIntegration
import de.md5lukas.waypoints.integrations.SquareMapIntegration
import de.md5lukas.waypoints.pointers.BeaconColor
import de.md5lukas.waypoints.pointers.WaypointTrackable
import de.md5lukas.waypoints.util.*
import net.kyori.adventure.text.Component
Expand Down Expand Up @@ -72,6 +73,10 @@ class WaypointPage(wpGUI: WaypointsGUI, private val waypoint: Waypoint) :
Type.PERMISSION -> wpGUI.viewer.hasPermission(WaypointsPermissions.MODIFY_PERMISSION)
}

override fun update() {
wpGUI.skedule { updatePage() }
}

private suspend fun updatePage(update: Boolean = true) {
applyPattern(
waypointPattern,
Expand Down Expand Up @@ -312,10 +317,15 @@ class WaypointPage(wpGUI: WaypointsGUI, private val waypoint: Waypoint) :
if (canModifyWaypoint &&
isNotDeathWaypoint &&
wpGUI.plugin.waypointsConfig.pointers.beacon.enabled) {
GUIItem(wpGUI.translations.WAYPOINT_SELECT_BEACON_COLOR.item) {
wpGUI.open(SelectBeaconColorPage(wpGUI, waypoint))
wpGUI.playSound { clickNormal }
}
GUIItem(
wpGUI.translations.WAYPOINT_SELECT_BEACON_COLOR.getItem(
waypoint.beaconColor
?: (wpGUI.plugin.waypointsConfig.pointers.beacon.getDefaultColor(
waypoint.type) ?: BeaconColor.CLEAR)
.material)) {
wpGUI.open(SelectBeaconColorPage(wpGUI, waypoint))
wpGUI.playSound { clickNormal }
}
} else {
background
},
Expand Down
2 changes: 1 addition & 1 deletion waypoints/src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ inventory:
editDescription: PAPER
moveToFolder: CHEST_MINECART
teleport: ENDER_PEARL
selectBeaconColor: LIME_STAINED_GLASS
selectBeaconColor: GLASS
getUuid: COMMAND_BLOCK
share: SPYGLASS
editPermission: IRON_BARS
Expand Down

0 comments on commit 33d773d

Please sign in to comment.