Skip to content

Commit

Permalink
implement placeholder replacement in sb title
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei1058 committed Oct 8, 2023
1 parent 9bce6cd commit ca73e40
Show file tree
Hide file tree
Showing 19 changed files with 107 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>com.andrei1058.spigot.sidebar</groupId>
<artifactId>sidebar-pom</artifactId>
<packaging>pom</packaging>
<version>23.8-SNAPSHOT</version>
<version>23.10-SNAPSHOT</version>
<modules>
<module>sidebar-base</module>
<module>sidebar-v1_20_R1</module>
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.8-SNAPSHOT</version>
<version>23.10-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
1 change: 1 addition & 0 deletions sidebar-base/sidebar-base.iml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<facet type="minecraft" name="Minecraft">
<configuration>
<autoDetectTypes>
<platformType>ADVENTURE</platformType>
<platformType>SPIGOT</platformType>
</autoDetectTypes>
</configuration>
Expand Down
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.8-SNAPSHOT</version>
<version>23.10-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ public void sendRemove(Player player) {
@Override
public String getDisplayName() {
String t = displayName.getLine();

if (null != getPlaceholders()) {
for (PlaceholderProvider placeholderProvider : getPlaceholders()) {
if (t.contains(placeholderProvider.getPlaceholder())) {
t = t.replace(placeholderProvider.getPlaceholder(), placeholderProvider.getReplacement());
}
}
}
t = ChatColor.translateAlternateColorCodes('&',
SidebarManager.getInstance().getPapiSupport().replacePlaceholders(null, t)
);

if (t.length() > 16) {
t = t.substring(0, 16);
}
Expand Down
2 changes: 1 addition & 1 deletion sidebar-v1_16_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.8-SNAPSHOT</version>
<version>23.10-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ public void sendRemove(Player player) {
@Override
public IChatBaseComponent getDisplayName() {
String t = displayName.getLine();

if (null != getPlaceholders()) {
for (PlaceholderProvider placeholderProvider : getPlaceholders()) {
if (t.contains(placeholderProvider.getPlaceholder())) {
t = t.replace(placeholderProvider.getPlaceholder(), placeholderProvider.getReplacement());
}
}
}
t = ChatColor.translateAlternateColorCodes('&',
SidebarManager.getInstance().getPapiSupport().replacePlaceholders(null, t)
);

if (t.length() > 32) {
t = t.substring(0, 32);
}
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.8-SNAPSHOT</version>
<version>23.10-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,18 @@ public void sendRemove(Player player) {
@Override
public IChatBaseComponent getDisplayName() {
String t = displayName.getLine();

if (null != getPlaceholders()) {
for (PlaceholderProvider placeholderProvider : getPlaceholders()) {
if (t.contains(placeholderProvider.getPlaceholder())) {
t = t.replace(placeholderProvider.getPlaceholder(), placeholderProvider.getReplacement());
}
}
}
t = ChatColor.translateAlternateColorCodes('&',
SidebarManager.getInstance().getPapiSupport().replacePlaceholders(null, t)
);

if (t.length() > 32) {
t = t.substring(0, 32);
}
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.8-SNAPSHOT</version>
<version>23.10-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ public String getName() {
@Override
public IChatBaseComponent d() {
String t = displayName.getLine();

if (null != getPlaceholders()) {
for (PlaceholderProvider placeholderProvider : getPlaceholders()) {
if (t.contains(placeholderProvider.getPlaceholder())) {
t = t.replace(placeholderProvider.getPlaceholder(), placeholderProvider.getReplacement());
}
}
}
t = ChatColor.translateAlternateColorCodes('&',
SidebarManager.getInstance().getPapiSupport().replacePlaceholders(null, t)
);

if (t.length() > 32) {
t = t.substring(0, 32);
}
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.8-SNAPSHOT</version>
<version>23.10-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,18 @@ public String getName() {
@Override
public IChatBaseComponent d() {
String t = displayName.getLine();

if (null != getPlaceholders()) {
for (PlaceholderProvider placeholderProvider : getPlaceholders()) {
if (t.contains(placeholderProvider.getPlaceholder())) {
t = t.replace(placeholderProvider.getPlaceholder(), placeholderProvider.getReplacement());
}
}
}
t = ChatColor.translateAlternateColorCodes('&',
SidebarManager.getInstance().getPapiSupport().replacePlaceholders(null, t)
);

if (t.length() > 32) {
t = t.substring(0, 32);
}
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.8-SNAPSHOT</version>
<version>23.10-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,18 @@ public String getName() {
@Override
public IChatBaseComponent d() {
String t = displayName.getLine();

if (null != getPlaceholders()) {
for (PlaceholderProvider placeholderProvider : getPlaceholders()) {
if (t.contains(placeholderProvider.getPlaceholder())) {
t = t.replace(placeholderProvider.getPlaceholder(), placeholderProvider.getReplacement());
}
}
}
t = ChatColor.translateAlternateColorCodes('&',
SidebarManager.getInstance().getPapiSupport().replacePlaceholders(null, t)
);

if (t.length() > 32) {
t = t.substring(0, 32);
}
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.8-SNAPSHOT</version>
<version>23.10-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,18 @@ public String getName() {
@Override
public IChatBaseComponent d() {
String t = displayName.getLine();

if (null != getPlaceholders()) {
for (PlaceholderProvider placeholderProvider : getPlaceholders()) {
if (t.contains(placeholderProvider.getPlaceholder())) {
t = t.replace(placeholderProvider.getPlaceholder(), placeholderProvider.getReplacement());
}
}
}
t = ChatColor.translateAlternateColorCodes('&',
SidebarManager.getInstance().getPapiSupport().replacePlaceholders(null, t)
);

if (t.length() > 256) {
t = t.substring(0, 256);
}
Expand Down
2 changes: 1 addition & 1 deletion sidebar-v1_8_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.8-SNAPSHOT</version>
<version>23.10-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ public void sendRemove(Player player) {
@Override
public String getDisplayName() {
String t = displayName.getLine();

if (null != getPlaceholders()) {
for (PlaceholderProvider placeholderProvider : getPlaceholders()) {
if (t.contains(placeholderProvider.getPlaceholder())) {
t = t.replace(placeholderProvider.getPlaceholder(), placeholderProvider.getReplacement());
}
}
}
t = ChatColor.translateAlternateColorCodes('&',
SidebarManager.getInstance().getPapiSupport().replacePlaceholders(null, t)
);

if (t.length() > 16) {
t = t.substring(0, 16);
}
Expand Down

0 comments on commit ca73e40

Please sign in to comment.