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

Commit 834c856

Browse files
committed
Scoreboard Update
1 parent ecad8e2 commit 834c856

File tree

3 files changed

+52
-5
lines changed

3 files changed

+52
-5
lines changed

README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,3 +479,51 @@ repeatingTask(1, TimeUnit.SECONDS, 5, true){
479479
//This will run every second 5 times async
480480
}
481481
```
482+
483+
## Scoreboard
484+
We have made it easy to create scoreboards when using this API. Instead of have to create teams and score in the spigot api. You can just create a `UndefinedScoreboard` class. After that you can create line with `addEmptyLine()`, `addLine(String)` and `addValueLine(Int, String, String)`. (See below)
485+
486+
### Kotlin
487+
```kotlin
488+
player.scoreboard = Bukkit.getScoreboardManager().newScoreboard
489+
490+
UndefinedScoreboard("Test", player.scoreboard)
491+
.addLine("IDK")
492+
.addEmptyLine()
493+
.addEmptyLine()
494+
.addValueLine(0, "Prefix ", " Suffix")
495+
```
496+
497+
### Java
498+
```java
499+
ScoreboardManager manager = Bukkit.getScoreboardManager();
500+
player.setScoreboard(manager.getNewScoreboard());
501+
502+
UndefinedScoreboard board = new UndefinedScoreboard("Test", player.getScoreboard());
503+
board.addLine("IDK");
504+
board.addEmptyLine();
505+
board.addEmptyLine();
506+
board.addValueLine(0, "Prefix ", " Suffix");
507+
```
508+
509+
### Changing value line
510+
To be able to change a value line you can use the `setValueLine(Int, String, String)`. The `Int` is the id of the line. (See below)
511+
512+
#### Kotlin
513+
```kotlin
514+
board.setValueLine(0, "Prefix2 ", " Suffix2")
515+
516+
board.setValueLine(0, prefix = "Prefix2 ")
517+
518+
board.setValueLine(0, suffix = " Suffix")
519+
```
520+
521+
#### Java
522+
```java
523+
board.setValueLine(0, "Prefix2 ", " Suffix2");
524+
525+
board.setValueLine(0, "Prefix2 ", null);
526+
527+
board.setValueLine(0, null, " Suffix");
528+
```
529+

build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ publishing {
2525
create<MavenPublication>("maven") {
2626
groupId = "com.redmagic"
2727
artifactId = "UndefinedAPI"
28-
version = "0.3.61"
28+
version = "0.4.00"
2929

3030
from(components["java"])
3131
}
3232
}
3333
}
3434

3535
group = "com.redmagic"
36-
version = "0.3.61"
36+
version = "0.4.00"
3737

3838
repositories {
3939
mavenCentral()

src/main/java/com/redmagic/undefinedapi/scoreboard/UndefinedScoreboard.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.redmagic.undefinedapi.scoreboard
22

3-
import com.redmagic.undefinedapi.extension.createDummy
43
import net.kyori.adventure.text.Component
54
import org.bukkit.Bukkit
65
import org.bukkit.ChatColor
@@ -57,11 +56,11 @@ class UndefinedScoreboard(private val title: Component, private val scoreboard:
5756
val order = order(index)
5857
val team = scoreboard.registerNewTeam(id.toString())
5958

60-
team.addEntry(order + id.toString())
59+
team.addEntry(order)
6160
team.prefix(prefix)
6261
team.suffix(suffix)
6362

64-
objective.getScore(order + id.toString()).score = 0
63+
objective.getScore(order).score = 0
6564

6665
teamMap[id] = team
6766
index++

0 commit comments

Comments
 (0)