Use root locale for upper / lowercasing

This commit is contained in:
md_5 2018-01-12 08:17:44 +11:00
parent d600c9a526
commit 22bd43f725

View File

@ -11,6 +11,7 @@ import net.md_5.bungee.api.chat.HoverEvent;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.Locale;
public class BaseComponentSerializer public class BaseComponentSerializer
{ {
@ -19,7 +20,7 @@ public class BaseComponentSerializer
{ {
if ( object.has( "color" ) ) if ( object.has( "color" ) )
{ {
component.setColor( ChatColor.valueOf( object.get( "color" ).getAsString().toUpperCase() ) ); component.setColor( ChatColor.valueOf( object.get( "color" ).getAsString().toUpperCase( Locale.ROOT ) ) );
} }
if ( object.has( "bold" ) ) if ( object.has( "bold" ) )
{ {
@ -55,7 +56,7 @@ public class BaseComponentSerializer
{ {
JsonObject event = object.getAsJsonObject( "clickEvent" ); JsonObject event = object.getAsJsonObject( "clickEvent" );
component.setClickEvent( new ClickEvent( component.setClickEvent( new ClickEvent(
ClickEvent.Action.valueOf( event.get( "action" ).getAsString().toUpperCase() ), ClickEvent.Action.valueOf( event.get( "action" ).getAsString().toUpperCase( Locale.ROOT ) ),
event.get( "value" ).getAsString() ) ); event.get( "value" ).getAsString() ) );
} }
if ( object.has( "hoverEvent" ) ) if ( object.has( "hoverEvent" ) )
@ -72,7 +73,7 @@ public class BaseComponentSerializer
context.<BaseComponent>deserialize( event.get( "value" ), BaseComponent.class ) context.<BaseComponent>deserialize( event.get( "value" ), BaseComponent.class )
}; };
} }
component.setHoverEvent( new HoverEvent( HoverEvent.Action.valueOf( event.get( "action" ).getAsString().toUpperCase() ), res ) ); component.setHoverEvent( new HoverEvent( HoverEvent.Action.valueOf( event.get( "action" ).getAsString().toUpperCase( Locale.ROOT ) ), res ) );
} }
} }
@ -126,14 +127,14 @@ public class BaseComponentSerializer
if ( component.getClickEvent() != null ) if ( component.getClickEvent() != null )
{ {
JsonObject clickEvent = new JsonObject(); JsonObject clickEvent = new JsonObject();
clickEvent.addProperty( "action", component.getClickEvent().getAction().toString().toLowerCase() ); clickEvent.addProperty( "action", component.getClickEvent().getAction().toString().toLowerCase( Locale.ROOT ) );
clickEvent.addProperty( "value", component.getClickEvent().getValue() ); clickEvent.addProperty( "value", component.getClickEvent().getValue() );
object.add( "clickEvent", clickEvent ); object.add( "clickEvent", clickEvent );
} }
if ( component.getHoverEvent() != null ) if ( component.getHoverEvent() != null )
{ {
JsonObject hoverEvent = new JsonObject(); JsonObject hoverEvent = new JsonObject();
hoverEvent.addProperty( "action", component.getHoverEvent().getAction().toString().toLowerCase() ); hoverEvent.addProperty( "action", component.getHoverEvent().getAction().toString().toLowerCase( Locale.ROOT ) );
hoverEvent.add( "value", context.serialize( component.getHoverEvent().getValue() ) ); hoverEvent.add( "value", context.serialize( component.getHoverEvent().getValue() ) );
object.add( "hoverEvent", hoverEvent ); object.add( "hoverEvent", hoverEvent );
} }