#3540: Add TextComponent#fromLegacy() as an array-free alternative to #fromLegacyText()
This commit is contained in:
@@ -105,13 +105,13 @@ public class ServerPing
|
||||
@Deprecated
|
||||
public ServerPing(Protocol version, Players players, String description, String favicon)
|
||||
{
|
||||
this( version, players, new TextComponent( TextComponent.fromLegacyText( description ) ), favicon == null ? null : Favicon.create( favicon ) );
|
||||
this( version, players, TextComponent.fromLegacy( description ), favicon == null ? null : Favicon.create( favicon ) );
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ServerPing(Protocol version, Players players, String description, Favicon favicon)
|
||||
{
|
||||
this( version, players, new TextComponent( TextComponent.fromLegacyText( description ) ), favicon );
|
||||
this( version, players, TextComponent.fromLegacy( description ), favicon );
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@@ -139,7 +139,7 @@ public class ServerPing
|
||||
@Deprecated
|
||||
public void setDescription(String description)
|
||||
{
|
||||
this.description = new TextComponent( TextComponent.fromLegacyText( description ) );
|
||||
this.description = TextComponent.fromLegacy( description );
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
|
@@ -1,9 +1,7 @@
|
||||
package net.md_5.bungee.api.event;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import net.md_5.bungee.api.Callback;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
@@ -27,8 +25,7 @@ public class LoginEvent extends AsyncEvent<LoginEvent> implements Cancellable
|
||||
/**
|
||||
* Message to use when kicking if this event is canceled.
|
||||
*/
|
||||
@Setter(AccessLevel.NONE)
|
||||
private BaseComponent[] cancelReasonComponents;
|
||||
private BaseComponent reason;
|
||||
/**
|
||||
* Connection attempting to login.
|
||||
*/
|
||||
@@ -42,28 +39,44 @@ public class LoginEvent extends AsyncEvent<LoginEvent> implements Cancellable
|
||||
|
||||
/**
|
||||
* @return reason to be displayed
|
||||
* @deprecated Use component methods instead.
|
||||
* @deprecated use component methods instead
|
||||
*/
|
||||
@Deprecated
|
||||
public String getCancelReason()
|
||||
{
|
||||
return BaseComponent.toLegacyText( getCancelReasonComponents() );
|
||||
return TextComponent.toLegacyText( getReason() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cancelReason reason to be displayed
|
||||
* @deprecated Use
|
||||
* {@link #setCancelReason(net.md_5.bungee.api.chat.BaseComponent...)}
|
||||
* instead.
|
||||
* @deprecated use component methods instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void setCancelReason(String cancelReason)
|
||||
{
|
||||
setCancelReason( TextComponent.fromLegacyText( cancelReason ) );
|
||||
setReason( TextComponent.fromLegacy( cancelReason ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return reason to be displayed
|
||||
* @deprecated use single component methods instead
|
||||
*/
|
||||
@Deprecated
|
||||
public BaseComponent[] getCancelReasonComponents()
|
||||
{
|
||||
return new BaseComponent[]
|
||||
{
|
||||
getReason()
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cancelReason reason to be displayed
|
||||
* @deprecated use single component methods instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void setCancelReason(BaseComponent... cancelReason)
|
||||
{
|
||||
this.cancelReasonComponents = cancelReason;
|
||||
setReason( TextComponent.fromArray( cancelReason ) );
|
||||
}
|
||||
}
|
||||
|
@@ -1,9 +1,7 @@
|
||||
package net.md_5.bungee.api.event;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import net.md_5.bungee.api.Callback;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
@@ -32,8 +30,7 @@ public class PreLoginEvent extends AsyncEvent<PreLoginEvent> implements Cancella
|
||||
/**
|
||||
* Message to use when kicking if this event is canceled.
|
||||
*/
|
||||
@Setter(AccessLevel.NONE)
|
||||
private BaseComponent[] cancelReasonComponents;
|
||||
private BaseComponent reason;
|
||||
/**
|
||||
* Connection attempting to login.
|
||||
*/
|
||||
@@ -47,28 +44,44 @@ public class PreLoginEvent extends AsyncEvent<PreLoginEvent> implements Cancella
|
||||
|
||||
/**
|
||||
* @return reason to be displayed
|
||||
* @deprecated Use component methods instead.
|
||||
* @deprecated use component methods instead
|
||||
*/
|
||||
@Deprecated
|
||||
public String getCancelReason()
|
||||
{
|
||||
return BaseComponent.toLegacyText( getCancelReasonComponents() );
|
||||
return BaseComponent.toLegacyText( getReason() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cancelReason reason to be displayed
|
||||
* @deprecated Use
|
||||
* {@link #setCancelReason(net.md_5.bungee.api.chat.BaseComponent...)}
|
||||
* instead.
|
||||
* @deprecated Use component methods instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void setCancelReason(String cancelReason)
|
||||
{
|
||||
setCancelReason( TextComponent.fromLegacyText( cancelReason ) );
|
||||
setReason( TextComponent.fromLegacy( cancelReason ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return reason to be displayed
|
||||
* @deprecated use single component methods instead
|
||||
*/
|
||||
@Deprecated
|
||||
public BaseComponent[] getCancelReasonComponents()
|
||||
{
|
||||
return new BaseComponent[]
|
||||
{
|
||||
getReason()
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cancelReason reason to be displayed
|
||||
* @deprecated use single component methods instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void setCancelReason(BaseComponent... cancelReason)
|
||||
{
|
||||
this.cancelReasonComponents = cancelReason;
|
||||
setReason( TextComponent.fromArray( cancelReason ) );
|
||||
}
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ public class ServerKickEvent extends Event implements Cancellable
|
||||
/**
|
||||
* Kick reason.
|
||||
*/
|
||||
private BaseComponent[] kickReasonComponent;
|
||||
private BaseComponent reason;
|
||||
/**
|
||||
* Server to send player to if this event is cancelled.
|
||||
*/
|
||||
@@ -63,24 +63,61 @@ public class ServerKickEvent extends Event implements Cancellable
|
||||
this( player, player.getServer().getInfo(), kickReasonComponent, cancelServer, state );
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ServerKickEvent(ProxiedPlayer player, ServerInfo kickedFrom, BaseComponent[] kickReasonComponent, ServerInfo cancelServer, State state)
|
||||
{
|
||||
this( player, kickedFrom, TextComponent.fromArray( kickReasonComponent ), cancelServer, state );
|
||||
}
|
||||
|
||||
public ServerKickEvent(ProxiedPlayer player, ServerInfo kickedFrom, BaseComponent reason, ServerInfo cancelServer, State state)
|
||||
{
|
||||
this.player = player;
|
||||
this.kickedFrom = kickedFrom;
|
||||
this.kickReasonComponent = kickReasonComponent;
|
||||
this.reason = reason;
|
||||
this.cancelServer = cancelServer;
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the kick reason
|
||||
* @deprecated use component methods instead
|
||||
*/
|
||||
@Deprecated
|
||||
public String getKickReason()
|
||||
{
|
||||
return BaseComponent.toLegacyText( kickReasonComponent );
|
||||
return BaseComponent.toLegacyText( getReason() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param reason the kick reason
|
||||
* @deprecated use component methods instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void setKickReason(String reason)
|
||||
{
|
||||
kickReasonComponent = TextComponent.fromLegacyText( reason );
|
||||
this.setReason( TextComponent.fromLegacy( reason ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the kick reason
|
||||
* @deprecated use single component methods instead
|
||||
*/
|
||||
@Deprecated
|
||||
public BaseComponent[] getKickReasonComponent()
|
||||
{
|
||||
return new BaseComponent[]
|
||||
{
|
||||
getReason()
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param kickReasonComponent the kick reason
|
||||
* @deprecated use single component methods instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void setKickReasonComponent(BaseComponent[] kickReasonComponent)
|
||||
{
|
||||
this.setReason( TextComponent.fromArray( kickReasonComponent ) );
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user