PlotSquared/src/main/java/com/plotsquared/bukkit/util/BukkitPlainChatManager.java

49 lines
1.4 KiB
Java
Raw Normal View History

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.object.PlotMessage;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.ChatManager;
2015-09-13 06:04:31 +02:00
public class BukkitPlainChatManager extends ChatManager<List<StringBuilder>> {
2015-08-26 00:35:32 +02:00
@Override
2015-09-13 06:04:31 +02:00
public List<StringBuilder> builder() {
2015-08-26 00:35:32 +02:00
return new ArrayList<StringBuilder>();
}
2015-09-13 06:04:31 +02:00
2015-08-26 00:35:32 +02:00
@Override
2015-09-13 06:04:31 +02:00
public void color(final PlotMessage m, final String color) {
2015-09-11 12:09:22 +02:00
final List<StringBuilder> parts = m.$(this);
2015-08-26 00:35:32 +02:00
parts.get(parts.size() - 1).insert(0, color);
}
2015-09-13 06:04:31 +02:00
2015-08-26 00:35:32 +02:00
@Override
2015-09-13 06:04:31 +02:00
public void tooltip(final PlotMessage m, final PlotMessage... tooltips) {}
2015-08-26 00:35:32 +02:00
@Override
2015-09-13 06:04:31 +02:00
public void command(final PlotMessage m, final String command) {}
2015-08-26 00:35:32 +02:00
@Override
2015-09-13 06:04:31 +02:00
public void text(final PlotMessage m, final String text) {
2015-08-26 00:35:32 +02:00
m.$(this).add(new StringBuilder(ChatColor.stripColor(text)));
}
2015-09-13 06:04:31 +02:00
2015-08-26 00:35:32 +02:00
@Override
2015-09-13 06:04:31 +02:00
public void send(final PlotMessage m, final PlotPlayer player) {
2015-09-11 12:09:22 +02:00
final StringBuilder built = new StringBuilder();
2015-09-13 06:04:31 +02:00
for (final StringBuilder sb : m.$(this)) {
2015-08-26 00:35:32 +02:00
built.append(sb);
}
player.sendMessage(built.toString());
}
2015-09-13 06:04:31 +02:00
2015-08-26 00:35:32 +02:00
@Override
2015-09-13 06:04:31 +02:00
public void suggest(final PlotMessage m, final String command) {}
2015-08-26 00:35:32 +02:00
}