mirror of
https://github.com/SpigotMC/BungeeCord.git
synced 2024-11-16 07:15:15 +01:00
Use BaseComponents instead of Strings
This commit is contained in:
parent
faa8075e39
commit
8a62980348
@ -4,6 +4,7 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.plugin.Cancellable;
|
||||
import net.md_5.bungee.api.plugin.Event;
|
||||
|
||||
@ -29,17 +30,17 @@ public class CommandEvent extends Event implements Cancellable
|
||||
/**
|
||||
* Sent to sender when executed command is cancelled.
|
||||
*/
|
||||
private String cancelledMessage;
|
||||
private BaseComponent cancelledMessage;
|
||||
|
||||
/**
|
||||
* Sent to the sender when sender has no permission to execute the command.
|
||||
*/
|
||||
private String notPermittedMessage;
|
||||
private BaseComponent notPermittedMessage;
|
||||
|
||||
/**
|
||||
* Sent to the sender when executed command is unknown.
|
||||
*/
|
||||
private String notFoundMessage;
|
||||
private BaseComponent notFoundMessage;
|
||||
|
||||
/**
|
||||
* If true, no messages will be displayed to the sender.
|
||||
@ -92,7 +93,7 @@ public class CommandEvent extends Event implements Cancellable
|
||||
*
|
||||
* @param cancelledMessage New message that will be sent to the sender if the event is cancelled
|
||||
*/
|
||||
public void setCancelledMessage(String cancelledMessage)
|
||||
public void setCancelledMessage(BaseComponent cancelledMessage)
|
||||
{
|
||||
this.cancelledMessage = cancelledMessage;
|
||||
}
|
||||
@ -102,7 +103,7 @@ public class CommandEvent extends Event implements Cancellable
|
||||
*
|
||||
* @param notPermittedMessage New message that will be sent to the sender if the sender is not permitted to execute the command.
|
||||
*/
|
||||
public void setNotPermittedMessage(String notPermittedMessage)
|
||||
public void setNotPermittedMessage(BaseComponent notPermittedMessage)
|
||||
{
|
||||
this.notPermittedMessage = notPermittedMessage;
|
||||
}
|
||||
@ -112,7 +113,7 @@ public class CommandEvent extends Event implements Cancellable
|
||||
*
|
||||
* @param notFoundMessage New message that will be sent to the sender if the command could not be found.
|
||||
*/
|
||||
public void setNotFoundMessage(String notFoundMessage)
|
||||
public void setNotFoundMessage(BaseComponent notFoundMessage)
|
||||
{
|
||||
this.notFoundMessage = notFoundMessage;
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.CommandEvent;
|
||||
@ -199,14 +200,14 @@ public final class PluginManager
|
||||
{
|
||||
if ( !commandEvent.isSuppressMessages() )
|
||||
{
|
||||
String noPermission = commandEvent.getNotPermittedMessage();
|
||||
BaseComponent noPermission = commandEvent.getNotPermittedMessage();
|
||||
|
||||
if ( noPermission == null )
|
||||
{
|
||||
noPermission = command.getPermissionMessage() == null ? this.proxy.getTranslation( "no_permission" ) : command.getPermissionMessage();
|
||||
noPermission = new ComponentBuilder( command.getPermissionMessage() == null ? this.proxy.getTranslation( "no_permission" ) : command.getPermissionMessage() ).getCurrentComponent();
|
||||
}
|
||||
|
||||
sender.sendMessage( new ComponentBuilder( noPermission ).create() );
|
||||
sender.sendMessage( noPermission );
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@ -240,13 +241,13 @@ public final class PluginManager
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean sendCommandEventMessage(CommandSender sender, CommandEvent commandEvent, String message)
|
||||
private boolean sendCommandEventMessage(CommandSender sender, CommandEvent commandEvent, BaseComponent message)
|
||||
{
|
||||
if ( !commandEvent.isSuppressMessages() )
|
||||
{
|
||||
if ( message != null )
|
||||
{
|
||||
sender.sendMessage( new ComponentBuilder( message ).create() );
|
||||
sender.sendMessage( message );
|
||||
return true;
|
||||
}
|
||||
} else
|
||||
|
Loading…
Reference in New Issue
Block a user