Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add spigot 1.21 r1 support #52

Merged
merged 6 commits into from
Aug 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/compile_snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ jobs:
name: development
url: https://repo.andrei1058.dev
steps:
- uses: actions/checkout@v2
- name: Set up JDK 17.0.4
uses: actions/setup-java@v2
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '17.0.4'
java-version: '21'
distribution: 'adopt'
- name: Deploy snapshot with Maven
env:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
name: production
url: https://repo.andrei1058.com
steps:
- uses: actions/checkout@v2
- name: Set up JDK 17.0.4
uses: actions/setup-java@v2
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '17.0.4'
java-version: '21'
distribution: 'adopt'
- name: Deploy with Maven
env:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/deploy_snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ jobs:
name: development
url: https://repo.andrei1058.dev/snapshots
steps:
- uses: actions/checkout@v2
- name: Set up JDK 17.0.4
uses: actions/setup-java@v2
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '17.0.4'
java-version: '21'
distribution: 'adopt'
- name: Deploy snapshot with Maven
env:
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
This is a NMS based scoreboard library for Minecraft plugins (spigot, paper).
[![Discord](https://discordapp.com/api/guilds/201345265821679617/widget.png?style=shield)](https://discord.gg/XdJfN2X)

**NOTICE:** Sidebar scores were removed from the right side in sidebar-v_1_20_R3.
**NOTICE:** Sidebar scores were removed from the right from version sidebar-v_1_20_R3.

![image](.github/sidebar_1.20.3.png)

Expand All @@ -20,6 +20,7 @@ This project is divided in several modules:
- `sidebar-v_1_20_R2` provides support for 1.20.2 (R2)
- `sidebar-v_1_20_R3` provides support for 1.20.3 (R3)
- `sidebar-v_1_20_R4` provides support for 1.20.4 (R4). Requires `sidebar-v_1_20_R3`.
- `sidebar-v_1_21_R1` provides support for 1.21.1 (R1). Requires `sidebar-cmn1`.

### IMPORTANT
It is really important to call Sidebar#remove(player) when a player leaves the server to avoid memory leaks.
Expand Down Expand Up @@ -272,7 +273,7 @@ Since 1.20.3 we can replace sidebar score numbers with string placeholders. You
<dependency>
<groupId>com.andrei1058.spigot.sidebar</groupId>
<artifactId>sidebar-base</artifactId>
<version>version-here</version>
<version>24.8</version> // make sure this is the latest
<scope>compile</scope>
</dependency>

Expand Down
4 changes: 3 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
<groupId>com.andrei1058.spigot.sidebar</groupId>
<artifactId>sidebar-pom</artifactId>
<packaging>pom</packaging>
<version>23.12.1-SNAPSHOT</version>
<version>24.8-SNAPSHOT</version>
<modules>
<module>sidebar-base</module>
<module>sidebar-v1_21_R1</module>
<module>sidebar-v1_20_R4</module>
<module>sidebar-v1_20_R3</module>
<module>sidebar-v1_20_R2</module>
Expand All @@ -21,6 +22,7 @@
<module>sidebar-v1_16_R3</module>
<module>sidebar-v1_12_R1</module>
<module>sidebar-v1_8_R3</module>
<module>sidebar-cmn1</module>
</modules>

<repositories>
Expand Down
2 changes: 1 addition & 1 deletion sidebar-base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>sidebar-pom</artifactId>
<groupId>com.andrei1058.spigot.sidebar</groupId>
<version>23.12.1-SNAPSHOT</version>
<version>24.8-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import java.util.*;
import java.util.concurrent.ConcurrentLinkedQueue;

public class WrappedSidebar implements Sidebar {
public abstract class WrappedSidebar implements Sidebar {

// sidebar lines
private final LinkedList<ScoreLine> lines = new LinkedList<>();
Expand Down
43 changes: 43 additions & 0 deletions sidebar-cmn1/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.andrei1058.spigot.sidebar</groupId>
<artifactId>sidebar-pom</artifactId>
<version>24.8-SNAPSHOT</version>
</parent>

<artifactId>sidebar-cmn1</artifactId>

<properties>
<maven.compiler.source>20</maven.compiler.source>
<maven.compiler.target>20</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<description>NMS version commons 1. For 1.20 and 1.21 where server version was removed from package name.</description>

<repositories>
<repository>
<id>nms</id>
<url>https://repo.codemc.io/repository/nms/</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>com.andrei1058.spigot.sidebar</groupId>
<artifactId>sidebar-base</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.21.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
package dev.andrei1058.spigot.sidebar.cmn1;

import com.andrei1058.spigot.sidebar.*;
import net.minecraft.network.chat.IChatBaseComponent;
import net.minecraft.network.chat.IChatMutableComponent;
import net.minecraft.world.scores.ScoreboardTeamBase;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

import javax.annotation.Nullable;
import java.util.Collection;

public class PlayerListImplCmn1 {
private ScoreboardTeamBase.EnumTeamPush pushingRule;
private final SidebarLine prefix;
private IChatMutableComponent prefixComp = IChatBaseComponent.b(" ");
private final SidebarLine suffix;
private IChatMutableComponent suffixComp = IChatBaseComponent.b(" ");
private final WrappedSidebar sidebar;
private final String id;
private ScoreboardTeamBase.EnumNameTagVisibility nameTagVisibility = ScoreboardTeamBase.EnumNameTagVisibility.a;
private Player papiSubject = null;
private final Collection<PlaceholderProvider> placeholders;

public PlayerListImplCmn1(
@NotNull WrappedSidebar sidebar,
String identifier,
SidebarLine prefix,
SidebarLine suffix,
PlayerTab.PushingRule pushingRule,
PlayerTab.NameTagVisibility nameTagVisibility,
@Nullable Collection<PlaceholderProvider> placeholders
) {
this.suffix = suffix;
this.prefix = prefix;
this.sidebar = sidebar;
setPushingRule(toNmsPushing(pushingRule));
setNameTagVisibility(toNmsTagVisibility(nameTagVisibility));
this.id = identifier;
this.placeholders = placeholders;
}

public ScoreboardTeamBase.EnumTeamPush toNmsPushing(PlayerTab.@NotNull PushingRule rule) {
return switch (rule) {
case NEVER -> ScoreboardTeamBase.EnumTeamPush.b;
case ALWAYS -> ScoreboardTeamBase.EnumTeamPush.a;
case PUSH_OTHER_TEAMS -> ScoreboardTeamBase.EnumTeamPush.c;
case PUSH_OWN_TEAM -> ScoreboardTeamBase.EnumTeamPush.d;
};
}

public ScoreboardTeamBase.EnumNameTagVisibility toNmsTagVisibility(PlayerTab.@NotNull NameTagVisibility nameTagVisibility) {
return switch (nameTagVisibility) {
case NEVER -> ScoreboardTeamBase.EnumNameTagVisibility.b;
case ALWAYS -> ScoreboardTeamBase.EnumNameTagVisibility.a;
case HIDE_FOR_OTHER_TEAMS -> ScoreboardTeamBase.EnumNameTagVisibility.c;
case HIDE_FOR_OWN_TEAM -> ScoreboardTeamBase.EnumNameTagVisibility.d;
};
}


public ScoreboardTeamBase.EnumTeamPush getPushingRule() {
return pushingRule;
}

public void setPushingRule(ScoreboardTeamBase.EnumTeamPush pushingRule) {
this.pushingRule = pushingRule;
}

public SidebarLine getPrefix() {
return prefix;
}

public IChatMutableComponent getPrefixComp() {
return prefixComp;
}

public void setPrefixComp(IChatMutableComponent prefixComp) {
this.prefixComp = prefixComp;
}

public SidebarLine getSuffix() {
return suffix;
}

public IChatMutableComponent getSuffixComp() {
return suffixComp;
}

public void setSuffixComp(IChatMutableComponent suffixComp) {
this.suffixComp = suffixComp;
}

public WrappedSidebar getSidebar() {
return sidebar;
}

public String getId() {
return id;
}

public ScoreboardTeamBase.EnumNameTagVisibility getNameTagVisibility() {
return nameTagVisibility;
}

public void setNameTagVisibility(ScoreboardTeamBase.EnumNameTagVisibility nameTagVisibility) {
this.nameTagVisibility = nameTagVisibility;
}

public Player getPapiSubject() {
return papiSubject;
}

public void setPapiSubject(Player papiSubject) {
this.papiSubject = papiSubject;
}

public Collection<PlaceholderProvider> getPlaceholders() {
return placeholders;
}

public boolean refreshContent() {
var newPrefix = prefix.getTrimReplacePlaceholders(papiSubject, 256, this.placeholders);
var newSuffix = suffix.getTrimReplacePlaceholders(papiSubject, 256, this.placeholders);

if (newPrefix.equals(prefixComp.getString()) && newSuffix.equals(suffixComp.getString())) {
return false;
}

this.prefixComp = IChatBaseComponent.b(newPrefix);
this.suffixComp = IChatBaseComponent.b(newSuffix);
return true;
}
}
2 changes: 1 addition & 1 deletion sidebar-v1_12_R1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>sidebar-pom</artifactId>
<groupId>com.andrei1058.spigot.sidebar</groupId>
<version>23.12.1-SNAPSHOT</version>
<version>24.8-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion sidebar-v1_16_R3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>sidebar-pom</artifactId>
<groupId>com.andrei1058.spigot.sidebar</groupId>
<version>23.12.1-SNAPSHOT</version>
<version>24.8-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion sidebar-v1_17_R1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>sidebar-pom</artifactId>
<groupId>com.andrei1058.spigot.sidebar</groupId>
<version>23.12.1-SNAPSHOT</version>
<version>24.8-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion sidebar-v1_18_R2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>sidebar-pom</artifactId>
<groupId>com.andrei1058.spigot.sidebar</groupId>
<version>23.12.1-SNAPSHOT</version>
<version>24.8-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion sidebar-v1_19_R2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>sidebar-pom</artifactId>
<groupId>com.andrei1058.spigot.sidebar</groupId>
<version>23.12.1-SNAPSHOT</version>
<version>24.8-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion sidebar-v1_19_R3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>sidebar-pom</artifactId>
<groupId>com.andrei1058.spigot.sidebar</groupId>
<version>23.12.1-SNAPSHOT</version>
<version>24.8-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion sidebar-v1_20_R1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>sidebar-pom</artifactId>
<groupId>com.andrei1058.spigot.sidebar</groupId>
<version>23.12.1-SNAPSHOT</version>
<version>24.8-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion sidebar-v1_20_R2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>sidebar-pom</artifactId>
<groupId>com.andrei1058.spigot.sidebar</groupId>
<version>23.12.1-SNAPSHOT</version>
<version>24.8-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion sidebar-v1_20_R3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>sidebar-pom</artifactId>
<groupId>com.andrei1058.spigot.sidebar</groupId>
<version>23.12.1-SNAPSHOT</version>
<version>24.8-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion sidebar-v1_20_R4/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>sidebar-pom</artifactId>
<groupId>com.andrei1058.spigot.sidebar</groupId>
<version>23.12.1-SNAPSHOT</version>
<version>24.8-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Loading