2020-04-16 04:52:39 +02:00
|
|
|
/*
|
|
|
|
* _____ _ _ _____ _
|
|
|
|
* | __ \| | | | / ____| | |
|
|
|
|
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
|
|
|
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
|
|
|
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
|
|
|
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
|
|
|
* | |
|
|
|
|
* |_|
|
|
|
|
* PlotSquared plot management system for Minecraft
|
|
|
|
* Copyright (C) 2020 IntellectualSites
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2020-04-11 02:19:18 +02:00
|
|
|
package com.plotsquared.bukkit.util;
|
2015-08-26 00:35:32 +02:00
|
|
|
|
2020-04-11 02:19:18 +02:00
|
|
|
import com.plotsquared.bukkit.chat.FancyMessage;
|
|
|
|
import com.plotsquared.bukkit.player.BukkitPlayer;
|
2020-04-16 06:14:33 +02:00
|
|
|
import com.plotsquared.core.configuration.Captions;
|
|
|
|
import com.plotsquared.core.configuration.Settings;
|
2020-04-15 21:26:54 +02:00
|
|
|
import com.plotsquared.core.player.ConsolePlayer;
|
|
|
|
import com.plotsquared.core.plot.message.PlotMessage;
|
|
|
|
import com.plotsquared.core.player.PlotPlayer;
|
|
|
|
import com.plotsquared.core.util.ChatManager;
|
2016-02-14 02:01:18 +01:00
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
|
2019-02-13 18:05:28 +01:00
|
|
|
import java.util.Arrays;
|
2016-02-14 02:01:18 +01:00
|
|
|
import java.util.List;
|
2019-02-13 18:05:28 +01:00
|
|
|
import java.util.stream.Collectors;
|
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
|
|
|
|
2018-08-10 17:01:10 +02:00
|
|
|
@Override public FancyMessage builder() {
|
2015-08-26 00:35:32 +02:00
|
|
|
return new FancyMessage("");
|
|
|
|
}
|
2016-02-14 02:01:18 +01:00
|
|
|
|
2018-08-10 17:01:10 +02:00
|
|
|
@Override public void color(PlotMessage message, String color) {
|
2019-02-22 17:51:06 +01:00
|
|
|
message.$(this).color(ChatColor.getByChar(Captions.color(color).substring(1)));
|
2015-08-26 00:35:32 +02:00
|
|
|
}
|
2016-02-14 02:01:18 +01:00
|
|
|
|
2018-08-10 17:01:10 +02:00
|
|
|
@Override public void tooltip(PlotMessage message, PlotMessage... tooltips) {
|
2019-02-13 18:05:28 +01:00
|
|
|
List<FancyMessage> lines =
|
|
|
|
Arrays.stream(tooltips).map(tooltip -> tooltip.$(this)).collect(Collectors.toList());
|
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
|
|
|
|
2018-08-10 17:01:10 +02:00
|
|
|
@Override public void command(PlotMessage message, String command) {
|
2016-04-19 22:59:10 +02:00
|
|
|
message.$(this).command(command);
|
2015-08-26 00:35:32 +02:00
|
|
|
}
|
2016-02-14 02:01:18 +01:00
|
|
|
|
2018-08-10 17:01:10 +02:00
|
|
|
@Override public void text(PlotMessage message, String text) {
|
2016-04-19 22:59:10 +02:00
|
|
|
message.$(this).then(ChatColor.stripColor(text));
|
2015-08-26 00:35:32 +02:00
|
|
|
}
|
2016-02-14 02:01:18 +01:00
|
|
|
|
2018-08-10 17:01:10 +02:00
|
|
|
@Override 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
|
|
|
|
2018-08-10 17:01:10 +02:00
|
|
|
@Override public void suggest(PlotMessage plotMessage, String command) {
|
2016-04-19 22:59:10 +02:00
|
|
|
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
|
|
|
}
|