Skip to content

Commit

Permalink
Merge pull request #44 from Andre601/feature/improve-velocity-ping-code
Browse files Browse the repository at this point in the history
Use ServerPing#asBuilder for pre-set values.
  • Loading branch information
Andre601 authored Apr 7, 2021
2 parents 593b55a + 8488ddf commit 6144a1f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<plugin.version>3.3.2</plugin.version>
<plugin.version>3.3.3</plugin.version>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
</properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public void onProxyPing(ProxyPingEvent event){
int userProtocol = protocolVersion.getProtocol();

List<Integer> serverProtocols = plugin.getConfigHandler().getIntList("Protocol", "Versions");
List<String> hoverMessage = plugin.getConfigHandler().getStringList("Messages", "Hover");

if(serverProtocols.isEmpty())
return;
Expand All @@ -59,9 +58,10 @@ public void onProxyPing(ProxyPingEvent event){

String playerCount = plugin.getConfigHandler().getString("", "Messages", "PlayerCount");
List<String> motd = plugin.getConfigHandler().getStringList("Messages", "Motd");
List<String> hoverMessage = plugin.getConfigHandler().getStringList("Messages", "Hover");

if(!serverProtocols.contains(userProtocol)){
ServerPing.Builder builder = ServerPing.builder();
ServerPing.Builder builder = ping.asBuilder();

if(!hoverMessage.isEmpty())
builder.samplePlayers(getSamplePlayers(hoverMessage, serverProtocols, userProtocol, majorOnly));
Expand All @@ -77,13 +77,8 @@ public void onProxyPing(ProxyPingEvent event){
motd = motd.subList(0, 1);

builder.description(Parser.toTextComponent(motd, serverProtocols, userProtocol, majorOnly));
}else{
builder.description(ping.getDescriptionComponent());
}

// Prevents breaking favicons
ping.getFavicon().ifPresent(builder::favicon);

event.setPing(builder.build());
}
}
Expand Down

0 comments on commit 6144a1f

Please sign in to comment.