1
0
Fork 0

#3629: Fix scoreboard team data reading

This commit is contained in:
Janmm14 2024-03-11 03:22:19 +00:00 committed by GitHub
parent 1b88a84710
commit 2394e204fa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 26 additions and 3 deletions

View File

@ -1,5 +1,6 @@
package net.md_5.bungee.protocol;
import java.util.function.Function;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Data;
@ -31,4 +32,26 @@ public final class Either<L, R>
{
return new Either<>( null, right );
}
public L getLeftOrCompute(Function<R, L> function)
{
if ( isLeft() )
{
return left;
} else
{
return function.apply( right );
}
}
public R getRightOrCompute(Function<L, R> function)
{
if ( isRight() )
{
return right;
} else
{
return function.apply( left );
}
}
}

View File

@ -267,9 +267,9 @@ public class DownstreamBridge extends PacketHandler
{
if ( team.getMode() == 0 || team.getMode() == 2 )
{
t.setDisplayName( ComponentSerializer.toString( team.getDisplayName() ) );
t.setPrefix( ComponentSerializer.toString( team.getPrefix() ) );
t.setSuffix( ComponentSerializer.toString( team.getSuffix() ) );
t.setDisplayName( team.getDisplayName().getLeftOrCompute( ComponentSerializer::toString ) );
t.setPrefix( team.getPrefix().getLeftOrCompute( ComponentSerializer::toString ) );
t.setSuffix( team.getSuffix().getLeftOrCompute( ComponentSerializer::toString ) );
t.setFriendlyFire( team.getFriendlyFire() );
t.setNameTagVisibility( team.getNameTagVisibility() );
t.setCollisionRule( team.getCollisionRule() );