Skip to content
This repository was archived by the owner on Nov 28, 2025. It is now read-only.

Commit f069ca8

Browse files
authored
Merge pull request #113 from DockyardMC/cleanup/random-things
Cleanup/random things
2 parents 80096ef + f00b85d commit f069ca8

File tree

119 files changed

+797
-581
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+797
-581
lines changed

.idea/inspectionProfiles/Project_Default.xml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 97 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,67 @@
1-
[![wakatime](https://wakatime.com/badge/github/DockyardMC/Dockyard.svg)](https://wakatime.com/badge/github/DockyardMC/Dockyard)
2-
[![Discord](https://img.shields.io/discord/1242845647892123650?label=Discord%20Server&color=%237289DA)](https://discord.gg/SA9nmfMkdc)
1+
![Maven metadata URL](https://img.shields.io/maven-metadata/v?metadataUrl=https%3A%2F%2Fmvn.devos.one%2Freleases%2Fio%2Fgithub%2Fdockyardmc%2Fdockyard%2Fmaven-metadata.xml&style=for-the-badge&logo=maven&logoColor=%23FFFFFF&label=Latest%20Version&color=%23afff87)
2+
![Static Badge](https://img.shields.io/badge/Language-Kotlin-Kotlin?style=for-the-badge&color=%23963cf4)
33

4-
# 🌊 DockyardMC 🚢
4+
[![wakatime](https://wakatime.com/badge/github/DockyardMC/Dockyard.svg?style=for-the-badge)](https://wakatime.com/badge/github/DockyardMC/Dockyard)
5+
[![Discord](https://img.shields.io/discord/1242845647892123650?label=Discord%20Server&color=%237289DA&style=for-the-badge&logo=discord&logoColor=%23FFFFFF)](https://discord.gg/SA9nmfMkdc)
6+
![Static Badge](https://img.shields.io/badge/Donate-Ko--Fi-pink?style=for-the-badge&logo=ko-fi&logoColor=%23FFFFFF&color=%23ff70c8)
57

6-
DockyardMC open-source, fast and lightweight Minecraft server protocol implementation that's written from scratch in Kotlin without any code from Mojang. It is focused on making development easy, unlike PaperMC which still uses some really old bukkit APIs, Dockyard has very easy to use and modern API
8+
# 🌊 <u>DockyardMC</u> 🚢
79

8-
> [!WARNING]
9-
> This project is currently under heavy development, and it is NOT production ready.
10+
DockyardMC is an open-source, fast and lightweight Minecraft server protocol implementation that's written from scratch in Kotlin without any code from Mojang. It is focused on making developing and prototyping easy, simple and intuitive while having full control over every aspect of the server.
11+
12+
**This project currently under development, missing parts some users might rely on**
1013

1114
## Quick Start
1215

13-
You can read how to setup and use dockyard here: https://dockyard.lukynka.cloud/wiki/quick-start
16+
You can read how to setup and use dockyard [here](https://dockyard.lukynka.cloud/wiki/quick-start)
1417

1518
## Features
1619

17-
- Easy to use, modern and extensible API
20+
- Modern, simple to use API which makes developing and prototyping easy and fast
21+
- Lightweight and without all the overhead the vanilla server has
1822
- Ability to take full control over every aspect of the server
19-
- Lightweight
20-
- uhhh there will be more stuff here later
23+
- Fully multithreaded worlds
2124

2225
## API Examples
2326

24-
#### Events
27+
### Events
2528

2629
```kotlin
27-
Events.on<PlayerConnectEvent> {
28-
DockyardServer.broadcastMessage("<lime>→ <yellow>${it.player} has joined the server.")
29-
}
30-
```
31-
32-
Modifying events (including PacketReceived and PacketSent)
33-
```kotlin
34-
Events.on<PacketReceivedEvent> {
35-
if(it.packet is ServerboundPlayerChatMessagePacket) {
36-
it.packet.message = "ha get overwritten >:3"
30+
Events.on<PlayerJoinEvent> { event ->
31+
if(banList.contains(event.player.uuid)) {
32+
event.player.kick("<red>You are banned!")
33+
event.cancel()
34+
return@on
3735
}
36+
37+
broadcastMessage("<lime>→ <yellow>${event.player} has joined the server.")
3838
}
3939
```
40-
Canceling Events
4140

41+
Modifying events (including PacketReceived and PacketSent)
4242
```kotlin
43-
Events.on<PlayerMoveEvent> {
44-
// No moving for aso >:3
45-
if(it.player.username == "AsoDesu_") {
46-
it.cancelled = true
43+
Events.on<PacketReceivedEvent> { event ->
44+
if(event.packet is ServerboundPlayerChatMessagePacket) {
45+
event.packet.message = "ha get overwritten >:3"
4746
}
4847
}
4948
```
5049
---
5150

52-
#### Commands API
51+
### Commands API
5352
You can create commands quickly and easily with the DockyardMC command API
5453

5554
```kotlin
5655
Commands.add("/explode") {
5756
addArgument("player", PlayerArgument())
5857
withPermission("player.admin")
59-
withDescription("executes stuff")
60-
execute {
61-
val executingPlayer = it.getPlayerOrThrow()
58+
withDescription("explodes a player")
59+
execute { context ->
60+
val executingPlayer = context.getPlayerOrThrow()
6261
val player = getArgument<Player>("player")
6362

6463
player.spawnParticle(player.location, Particles.EXPLOSION_EMITTER, Vector3f(1f), amount = 5)
65-
player.playSound("minecraft:entity.generic.explode", volume = 2f, pitch = MathUtils.randomFloat(0.6f, 1.3f))
64+
player.playSound(Sounds.ENTITY_GENERIC_EXPLODE, volume = 2f, pitch = randomFloat(0.6f, 1.3f))
6665

6766
player.sendMessage("<yellow>You got <rainbow><b>totally exploded <yellow>by <red>$executingPlayer")
6867
executingPlayer.sendMessage("<yellow>You <rainbow><b>totally exploded <yellow>player <red>$player")
@@ -72,49 +71,95 @@ Commands.add("/explode") {
7271

7372
---
7473

75-
#### Periodical Events
74+
### Built-in Bossbar and Sidebar APIs
7675

77-
Run code periodically
76+
#### Sidebar API
7877
```kotlin
79-
Period.on<HourPeriod> {
80-
DockyardServer.broadcastMessage("<aqua>Reminder: <yellow>Stay hydrated and stretch once in a while!")
78+
val sidebar = Sidebar {
79+
setTitle("<yellow><bold>My Cool Server")
80+
setGlobalLine("")
81+
setPlayerLine { player -> "Welcome, <aqua>$player" }
82+
setPlayerLine { player -> "World: <yellow>${player.world.name}" }
83+
setPlayerLine { player -> "Ping: <pink>${player.ping}" }
84+
setGlobalLine("")
85+
setGlobalLine("<yellow>www.mycoolserver.uwu")
86+
}
87+
88+
Events.on<PlayerJoinEvent> { event ->
89+
sidebar.viewers.add(event.player)
8190
}
8291
```
92+
Changing any lines, title etc. will automatically send update to the viewers
8393

84-
---
94+
#### Bossbar API
95+
```kotlin
96+
val bossbar = Bossbar("<yellow>The server has uptime is: <orange>$serverUptime<yellow>!", 1f, BossbarColor.YELLOW, BossbarNotches.SIX)
8597

86-
_there will be more later_
98+
Events.on<PlayerJoinEvent> { event ->
99+
bossbar.addViewer(event.player)
100+
}
101+
```
102+
Again, changing any properties of the bossbar will automatically send updates to the viewers
87103

88-
---
104+
### Entity Metadata Layers
89105

90-
## Run Locally
106+
Layering entity metadata per player allows for client-side changes to entities for purposes like client-side glowing and client-side invisibility.
91107

92-
- Clone the repository `git clone https://github.com/DockyardMC/Dockyard/`
93-
- Go to the project directory `cd Dockyard`
94-
- Open in IntelliJ and run task `Dockyard Server`
108+
Note that this behaviour is not just sending one packet, but its whole system that overlays the player specific metadata layer over the entity's actual metadata
109+
110+
Here are few examples:
111+
```kotlin
112+
// pre-made functions to set client-side glowing and invisibility
113+
entity.setGlowingFor(player, true)
114+
entity.setInvisibleFor(player, false)
115+
```
116+
117+
```kotlin
118+
// get the metadata layer of player or create new one if it doesn't exist
119+
val playerMetadataLayer = warden.metadataLayers[player] ?: mutableMapOf<EntityMetadataType, EntityMetadata>()
120+
121+
// create new EntityMetadata with index and type pose
122+
val pose = EntityMetadata(EntityMetadataType.POSE, EntityMetaValue.POSE, EntityPose.ROARING)
123+
124+
// add the pose to the list
125+
playerMetadataLayer[EntityMetadataType.POSE] = pose
126+
warden.metadataLayers[player] = playerMetadataLayer
127+
128+
// specified player will now see the warden roaring
129+
```
130+
131+
## Running
132+
133+
Dockyard is mainly designed as library that can be imported via maven. If you want to run dockyard you will need to embed it into your own kotlin app.
95134

96135
## Contributing
97136

98137
Contributions are always welcome! Please always check branches to see if the feature you are contributing is not already existing feature that someone else is working on
99138

139+
(plus you get cool fancy orange contributor role on the discord!!!)
140+
100141
## Related Libraries / Projects
101142

102-
- **Scroll**, Minecraft component library made for DockyardMC
103-
- https://github.com/DockyardMC/Scroll/
143+
- **[Scroll](https://github.com/DockyardMC/Scroll/)** - Minecraft component library made for DockyardMC
144+
- **[Chart](https://github.com/DockyardMC/Chart)** - Minecraft NBT library made for DockyardMC
145+
- **[kotlin-bindables](https://github.com/LukynkaCZE/kotlin-bindables)** - Bindable system inspired by [osu!framework](https://github.com/ppy/osu-framework/)
146+
- **[Pathetic](https://github.com/Metaphoriker/pathetic)** - A powerful, optimized and easy-to-use Java A* Pathfinding Library for 3D environments.
147+
- **[Spark](https://github.com/lucko/spark)** - A performance profiler for Minecraft clients, servers, and proxies
148+
- **[PrettyLog](https://github.com/LukynkaCZE/PrettyLog/)** - Fancy logging library
104149

105-
- **PrettyLog**, fancy logging library
106-
- https://github.com/LukynkaCZE/PrettyLog/
107150
## Authors
108151

109-
- [@LukynkaCZE](https://www.github.com/LukynkaCZE)
110-
- [@AsoDesu](https://www.github.com/AsoDesu)
152+
- [LukynkaCZE](https://www.github.com/LukynkaCZE)
153+
- [AsoDesu](https://www.github.com/AsoDesu)
111154

112155
## Additional thanks to
113156

114-
- [@KevDev](https://github.com/TrasherMC)
115-
- [@BluSpring](https://github.com/BluSpring)
116-
- [@Asoji](https://github.com/asoji)
157+
- [KevDev](https://github.com/TrasherMC)
158+
- [BluSpring](https://github.com/BluSpring)
159+
- [Asoji](https://github.com/asoji)
117160
- All the contributors
118161
- Twitch chat who watches me code this! <3
119162

120-
If you want to support me and this project, consider [buying me a coffee](https://ko-fi.com/lukynkacze)
163+
---
164+
165+
If you want to support me and this project, consider [**buying me a coffee**](https://ko-fi.com/lukynkacze) <3

src/main/kotlin/io/github/dockyardmc/entity/EntityMetadata.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import io.github.dockyardmc.scroll.Component
1111
import io.github.dockyardmc.utils.Quaternion
1212
import io.github.dockyardmc.utils.vectors.Vector3
1313
import io.github.dockyardmc.utils.vectors.Vector3f
14-
import io.github.dockyardmc.utils.vectors.writeVector3
15-
import io.github.dockyardmc.utils.vectors.writeVector3f
1614
import io.github.dockyardmc.utils.writeQuaternion
1715
import io.netty.buffer.ByteBuf
1816
import org.jglrxavpok.hephaistos.nbt.NBTCompound
@@ -47,7 +45,7 @@ fun ByteBuf.writeMetadata(metadata: EntityMetadata) {
4745
EntityMetaValue.OPTIONAL_TEXT_COMPONENT -> { this.writeBoolean(valuePresent); if(valuePresent) this.writeNBT((metadata.value as Component).toNBT()) }
4846
EntityMetaValue.ITEM_STACK -> (v as ItemStack).write(this)
4947
EntityMetaValue.BOOLEAN -> this.writeBoolean(v as Boolean)
50-
EntityMetaValue.ROTATION -> this.writeVector3f(v as Vector3f)
48+
EntityMetaValue.ROTATION -> (v as Vector3f).write(this)
5149
EntityMetaValue.POSITION -> this.writeLocation(v as Location)
5250
EntityMetaValue.OPTIONAL_POSITION -> { this.writeBoolean(valuePresent); if(valuePresent) this.writeLocation(v as Location)}
5351
EntityMetaValue.DIRECTION -> this.writeVarInt((v as Direction).ordinal)
@@ -56,15 +54,15 @@ fun ByteBuf.writeMetadata(metadata: EntityMetadata) {
5654
EntityMetaValue.OPTIONAL_BLOCK_STATE -> { this.writeBoolean(valuePresent); if(valuePresent) this.writeVarInt(v as Int)}
5755
EntityMetaValue.NBT -> this.writeNBT(v as NBTCompound)
5856
EntityMetaValue.PARTICLE -> TODO()
59-
EntityMetaValue.VILLAGER_DATA -> this.writeVector3(v as Vector3)
57+
EntityMetaValue.VILLAGER_DATA -> (v as Vector3).write(this)
6058
EntityMetaValue.OPTIONAL_VAR_INT -> { this.writeBoolean(valuePresent); if(valuePresent) this.writeVarInt(v as Int)}
6159
EntityMetaValue.POSE -> this.writeVarInt((v as EntityPose).ordinal)
6260
EntityMetaValue.CAT_VARIANT -> this.writeVarInt(v as Int)
6361
EntityMetaValue.FROG_VARIANT -> this.writeVarInt(v as Int)
6462
EntityMetaValue.OPTIONAL_GLOBAL_POSITION -> TODO()
6563
EntityMetaValue.PAINTING_VARIANT -> this.writeVarInt(v as Int)
6664
EntityMetaValue.SNIFFER_STATE -> this.writeVarInt(v as Int)
67-
EntityMetaValue.VECTOR3 -> this.writeVector3f(v as Vector3f)
65+
EntityMetaValue.VECTOR3 -> (v as Vector3f).write(this)
6866
EntityMetaValue.QUATERNION -> this.writeQuaternion(v as Quaternion)
6967
else -> throw Exception("noop in entity meta")
7068
}

src/main/kotlin/io/github/dockyardmc/events/ClientboundMoveVehiclePacket.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import io.github.dockyardmc.protocol.packets.ClientboundPacket
88
class ClientboundMoveVehiclePacket(var vehicle: Entity): ClientboundPacket() {
99

1010
init {
11-
data.writeLocation(vehicle.location)
12-
data.writeRotation(vehicle.location, false)
11+
buffer.writeLocation(vehicle.location)
12+
buffer.writeRotation(vehicle.location, false)
1313
}
1414

1515
}

src/main/kotlin/io/github/dockyardmc/events/InventoryClickEvent.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ package io.github.dockyardmc.events
22

33
import io.github.dockyardmc.player.Player
44

5-
class InventoryClickEvent(val player: Player, override val context: Event.Context): Event {
6-
}
5+
class InventoryClickEvent(val player: Player, override val context: Event.Context): Event

0 commit comments

Comments
 (0)