86 lines
2.7 KiB
Java
86 lines
2.7 KiB
Java
package cn.citycraft.TellRaw.manual;
|
|
|
|
import org.bukkit.Achievement;
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.Material;
|
|
import org.bukkit.Statistic;
|
|
import org.bukkit.command.CommandSender;
|
|
import org.bukkit.entity.EntityType;
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.inventory.ItemStack;
|
|
|
|
import cn.citycraft.TellRaw.FancyMessage;
|
|
import cn.citycraft.TellRaw.common.TextualComponent;
|
|
|
|
/**
|
|
* Represents a formattable message. Such messages can use elements such as
|
|
* colors, formatting codes, hover and click data, and other features provided
|
|
* by the vanilla Minecraft <a
|
|
* href="http://minecraft.gamepedia.com/Tellraw#Raw_JSON_Text">JSON message
|
|
* formatter</a>.
|
|
* This class allows plugins to emulate the functionality of the vanilla
|
|
* Minecraft <a href="http://minecraft.gamepedia.com/Commands#tellraw">tellraw
|
|
* command</a>.
|
|
* <p>
|
|
* This class follows the builder pattern, allowing for method chaining. It is
|
|
* set up such that invocations of property-setting methods will affect the
|
|
* current editing component, and a call to {@link #then()} or
|
|
* {@link #then(Object)} will append a new editing component to the end of the
|
|
* message, optionally initializing it with text. Further property-setting
|
|
* method calls will affect that editing component.
|
|
* </p>
|
|
*/
|
|
public class FancyMessageManual extends FancyMessage {
|
|
/**
|
|
* 新建手动序列化类
|
|
*/
|
|
public FancyMessageManual() {
|
|
this("");
|
|
}
|
|
|
|
/**
|
|
* 新建手动序列化类
|
|
*
|
|
* @param firstPartText
|
|
* 第一个文本串
|
|
*/
|
|
public FancyMessageManual(final String firstPartText) {
|
|
super(TextualComponent.rawText(firstPartText));
|
|
}
|
|
|
|
@Override
|
|
public FancyMessage achievementTooltip(final Achievement which) {
|
|
throw new UnsupportedOperationException("暂时不支持当前操作."); // To change body of generated methods, choose Tools | Templates.
|
|
}
|
|
|
|
@Override
|
|
public FancyMessage itemTooltip(final ItemStack itemStack) {
|
|
this.itemTooltip(new GItemStack(itemStack).toString());
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
public void send(final CommandSender sender, final String jsonString) {
|
|
if (sender instanceof Player) {
|
|
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "tellraw " + sender.getName() + " " + jsonString);
|
|
} else {
|
|
sender.sendMessage(toOldMessageFormat());
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public FancyMessage statisticTooltip(final Statistic which) {
|
|
throw new UnsupportedOperationException("暂时不支持当前操作.");
|
|
}
|
|
|
|
@Override
|
|
public FancyMessage statisticTooltip(final Statistic which, final EntityType entity) {
|
|
throw new UnsupportedOperationException("暂时不支持当前操作.");
|
|
}
|
|
|
|
@Override
|
|
public FancyMessage statisticTooltip(final Statistic which, final Material item) {
|
|
throw new UnsupportedOperationException("暂时不支持当前操作.");
|
|
}
|
|
}
|