2015-08-26 00:35:32 +02:00
|
|
|
package com.plotsquared.bukkit.util;
|
|
|
|
|
|
|
|
import com.intellectualcrafters.plot.config.C;
|
2016-06-13 06:47:50 +02:00
|
|
|
import com.intellectualcrafters.plot.config.Settings;
|
2015-08-26 00:35:32 +02:00
|
|
|
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
|
|
|
import com.intellectualcrafters.plot.object.PlotMessage;
|
|
|
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
|
|
|
import com.intellectualcrafters.plot.util.ChatManager;
|
|
|
|
import com.plotsquared.bukkit.chat.FancyMessage;
|
|
|
|
import com.plotsquared.bukkit.object.BukkitPlayer;
|
2016-02-14 02:01:18 +01:00
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
2015-08-26 00:35:32 +02:00
|
|
|
|
2015-09-13 06:04:31 +02:00
|
|
|
public class BukkitChatManager extends ChatManager<FancyMessage> {
|
2016-02-14 02:01:18 +01:00
|
|
|
|
2015-08-26 00:35:32 +02:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public FancyMessage builder() {
|
2015-08-26 00:35:32 +02:00
|
|
|
return new FancyMessage("");
|
|
|
|
}
|
2016-02-14 02:01:18 +01:00
|
|
|
|
2015-08-26 00:35:32 +02:00
|
|
|
@Override
|
2016-04-19 22:59:10 +02:00
|
|
|
public void color(PlotMessage message, String color) {
|
|
|
|
message.$(this).color(ChatColor.getByChar(C.color(color).substring(1)));
|
2015-08-26 00:35:32 +02:00
|
|
|
}
|
2016-02-14 02:01:18 +01:00
|
|
|
|
2015-08-26 00:35:32 +02:00
|
|
|
@Override
|
2016-04-19 22:59:10 +02:00
|
|
|
public void tooltip(PlotMessage message, PlotMessage... tooltips) {
|
2016-03-23 02:41:37 +01:00
|
|
|
List<FancyMessage> lines = new ArrayList<>();
|
|
|
|
for (PlotMessage tooltip : tooltips) {
|
2015-08-26 00:35:32 +02:00
|
|
|
lines.add(tooltip.$(this));
|
|
|
|
}
|
2016-04-19 22:59:10 +02:00
|
|
|
message.$(this).formattedTooltip(lines);
|
2015-08-26 00:35:32 +02:00
|
|
|
}
|
2016-02-14 02:01:18 +01:00
|
|
|
|
2015-08-26 00:35:32 +02:00
|
|
|
@Override
|
2016-04-19 22:59:10 +02:00
|
|
|
public void command(PlotMessage message, String command) {
|
|
|
|
message.$(this).command(command);
|
2015-08-26 00:35:32 +02:00
|
|
|
}
|
2016-02-14 02:01:18 +01:00
|
|
|
|
2015-08-26 00:35:32 +02:00
|
|
|
@Override
|
2016-04-19 22:59:10 +02:00
|
|
|
public void text(PlotMessage message, String text) {
|
|
|
|
message.$(this).then(ChatColor.stripColor(text));
|
2015-08-26 00:35:32 +02:00
|
|
|
}
|
2016-02-14 02:01:18 +01:00
|
|
|
|
2015-08-26 00:35:32 +02:00
|
|
|
@Override
|
2016-04-19 22:59:10 +02:00
|
|
|
public void send(PlotMessage plotMessage, PlotPlayer player) {
|
2016-06-13 06:47:50 +02:00
|
|
|
if (player instanceof ConsolePlayer || !Settings.Chat.INTERACTIVE) {
|
2016-04-19 22:59:10 +02:00
|
|
|
player.sendMessage(plotMessage.$(this).toOldMessageFormat());
|
2015-09-13 06:04:31 +02:00
|
|
|
} else {
|
2016-04-19 22:59:10 +02:00
|
|
|
plotMessage.$(this).send(((BukkitPlayer) player).player);
|
2015-08-26 00:35:32 +02:00
|
|
|
}
|
|
|
|
}
|
2016-02-14 02:01:18 +01:00
|
|
|
|
2015-08-26 00:35:32 +02:00
|
|
|
@Override
|
2016-04-19 22:59:10 +02:00
|
|
|
public void suggest(PlotMessage plotMessage, String command) {
|
|
|
|
plotMessage.$(this).suggest(command);
|
2015-08-26 00:35:32 +02:00
|
|
|
}
|
2016-02-14 02:01:18 +01:00
|
|
|
|
2015-08-26 00:35:32 +02:00
|
|
|
}
|