2015-08-26 00:35:32 +02:00
|
|
|
package com.plotsquared.bukkit.util;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
|
|
|
|
import com.intellectualcrafters.plot.config.C;
|
|
|
|
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;
|
|
|
|
|
2015-09-11 12:09:22 +02:00
|
|
|
public class BukkitChatManager extends ChatManager<FancyMessage>
|
|
|
|
{
|
|
|
|
|
2015-08-26 00:35:32 +02:00
|
|
|
@Override
|
2015-09-11 12:09:22 +02:00
|
|
|
public FancyMessage builder()
|
|
|
|
{
|
2015-08-26 00:35:32 +02:00
|
|
|
return new FancyMessage("");
|
|
|
|
}
|
2015-09-11 12:09:22 +02:00
|
|
|
|
2015-08-26 00:35:32 +02:00
|
|
|
@Override
|
2015-09-11 12:09:22 +02:00
|
|
|
public void color(final PlotMessage m, final String color)
|
|
|
|
{
|
2015-08-26 00:35:32 +02:00
|
|
|
m.$(this).color(ChatColor.getByChar(C.color(color).substring(1)));
|
|
|
|
}
|
2015-09-11 12:09:22 +02:00
|
|
|
|
2015-08-26 00:35:32 +02:00
|
|
|
@Override
|
2015-09-11 12:09:22 +02:00
|
|
|
public void tooltip(final PlotMessage m, final PlotMessage... tooltips)
|
|
|
|
{
|
|
|
|
final List<FancyMessage> lines = new ArrayList<>();
|
|
|
|
for (final PlotMessage tooltip : tooltips)
|
|
|
|
{
|
2015-08-26 00:35:32 +02:00
|
|
|
lines.add(tooltip.$(this));
|
|
|
|
}
|
|
|
|
m.$(this).formattedTooltip(lines);
|
|
|
|
}
|
2015-09-11 12:09:22 +02:00
|
|
|
|
2015-08-26 00:35:32 +02:00
|
|
|
@Override
|
2015-09-11 12:09:22 +02:00
|
|
|
public void command(final PlotMessage m, final String command)
|
|
|
|
{
|
2015-08-26 00:35:32 +02:00
|
|
|
m.$(this).command(command);
|
|
|
|
}
|
2015-09-11 12:09:22 +02:00
|
|
|
|
2015-08-26 00:35:32 +02:00
|
|
|
@Override
|
2015-09-11 12:09:22 +02:00
|
|
|
public void text(final PlotMessage m, final String text)
|
|
|
|
{
|
2015-08-26 00:35:32 +02:00
|
|
|
m.$(this).then(ChatColor.stripColor(text));
|
|
|
|
}
|
2015-09-11 12:09:22 +02:00
|
|
|
|
2015-08-26 00:35:32 +02:00
|
|
|
@Override
|
2015-09-11 12:09:22 +02:00
|
|
|
public void send(final PlotMessage m, final PlotPlayer player)
|
|
|
|
{
|
|
|
|
if (ConsolePlayer.isConsole(player))
|
|
|
|
{
|
2015-08-26 00:35:32 +02:00
|
|
|
player.sendMessage(m.$(this).toOldMessageFormat());
|
|
|
|
}
|
2015-09-11 12:09:22 +02:00
|
|
|
else
|
|
|
|
{
|
2015-08-26 00:35:32 +02:00
|
|
|
m.$(this).send(((BukkitPlayer) player).player);
|
|
|
|
}
|
|
|
|
}
|
2015-09-11 12:09:22 +02:00
|
|
|
|
2015-08-26 00:35:32 +02:00
|
|
|
@Override
|
2015-09-11 12:09:22 +02:00
|
|
|
public void suggest(final PlotMessage m, final String command)
|
|
|
|
{
|
2015-08-26 00:35:32 +02:00
|
|
|
m.$(this).suggest(command);
|
|
|
|
}
|
2015-09-11 12:09:22 +02:00
|
|
|
|
2015-08-26 00:35:32 +02:00
|
|
|
}
|