API changes

This commit is contained in:
Norbi Peti 2019-01-12 01:24:31 +01:00
parent 8ccf3ee9d7
commit 25ce2a4c9f
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
7 changed files with 362 additions and 358 deletions

View file

@ -7,10 +7,10 @@ import buttondevteam.chat.formatting.TellrawEvent;
import buttondevteam.chat.formatting.TellrawPart;
import buttondevteam.chat.formatting.TellrawSerializer;
import buttondevteam.chat.listener.PlayerListener;
import buttondevteam.component.channel.Channel;
import buttondevteam.lib.TBMCChatEvent;
import buttondevteam.lib.TBMCChatEventBase;
import buttondevteam.lib.TBMCCoreAPI;
import buttondevteam.lib.chat.Channel;
import buttondevteam.lib.chat.Color;
import buttondevteam.lib.chat.Priority;
import buttondevteam.lib.chat.TellrawSerializableEnum;
@ -114,7 +114,7 @@ public class ChatProcessing {
else //Due to the online player map, getPlayer() can be more efficient than getAs()
mp = e.getUser().getAs(ChatPlayer.class); //May be null
Color colormode = channel.color;
Color colormode = channel.Color().get();
if (mp != null && mp.OtherColorMode != null)
colormode = mp.OtherColorMode;
if (message.startsWith(">"))
@ -122,7 +122,7 @@ public class ChatProcessing {
// If greentext, ignore channel or player colors
ArrayList<ChatFormatter> formatters = addFormatters(colormode);
if (colormode == channel.color && mp != null && mp.RainbowPresserColorMode) { // Only overwrite channel color
if (colormode == channel.Color().get() && mp != null && mp.RainbowPresserColorMode) { // Only overwrite channel color
final AtomicInteger rpc = new AtomicInteger(0);
formatters.add(ChatFormatter.builder().color(colormode).onmatch((match, cf) -> {
cf.setColor(RainbowPresserColors[rpc.getAndUpdate(i -> ++i < RainbowPresserColors.length ? i : 0)]);
@ -233,7 +233,7 @@ public class ChatProcessing {
}
static String getChannelID(Channel channel, CommandSender sender, String origin) {
return ("[" + (MCORIGIN.equals(origin) ? "" : "§8" + origin.substring(0, 1) + "§r|") + channel.DisplayName)
return ("[" + (MCORIGIN.equals(origin) ? "" : "§8" + origin.substring(0, 1) + "§r|") + channel.DisplayName().get())
+ "]";
}

View file

@ -7,10 +7,10 @@ import buttondevteam.chat.components.TownyComponent;
import buttondevteam.chat.listener.PlayerJoinLeaveListener;
import buttondevteam.chat.listener.PlayerListener;
import buttondevteam.chat.listener.TownyListener;
import buttondevteam.component.channel.Channel;
import buttondevteam.component.channel.Channel.RecipientTestResult;
import buttondevteam.lib.TBMCCoreAPI;
import buttondevteam.lib.architecture.Component;
import buttondevteam.lib.chat.Channel;
import buttondevteam.lib.chat.Channel.RecipientTestResult;
import buttondevteam.lib.chat.Color;
import buttondevteam.lib.chat.TBMCChatAPI;
import buttondevteam.lib.player.TBMCPlayerBase;

View file

@ -1,7 +1,7 @@
package buttondevteam.chat.commands;
import buttondevteam.component.channel.Channel;
import buttondevteam.lib.TBMCChatEventBase;
import buttondevteam.lib.chat.Channel;
import buttondevteam.lib.chat.CommandClass;
import buttondevteam.lib.chat.TBMCCommandBase;
import lombok.Data;

View file

@ -1,6 +1,6 @@
package buttondevteam.chat.commands.ucmds;
import buttondevteam.lib.chat.Channel;
import buttondevteam.component.channel.Channel;
import buttondevteam.lib.chat.ChatMessage;
import buttondevteam.lib.chat.CommandClass;
import lombok.RequiredArgsConstructor;
@ -54,7 +54,7 @@ public class HistoryCommand extends UCommandBase {
for (int i = Math.max(0, arr.length - 10); i < arr.length; i++) {
HistoryEntry e = arr[i];
val cm = e.chatMessage;
sender.sendMessage("[" + e.channel.DisplayName + "] " + cm.getSender().getName() + ": " + cm.getMessage());
sender.sendMessage("[" + e.channel.DisplayName().get() + "] " + cm.getSender().getName() + ": " + cm.getMessage());
sent.set(true);
}
if (!sent.get())

View file

@ -2,7 +2,7 @@ package buttondevteam.chat.components;
import buttondevteam.chat.ChatProcessing;
import buttondevteam.chat.PluginMain;
import buttondevteam.lib.chat.Channel;
import buttondevteam.component.channel.Channel;
import buttondevteam.lib.chat.TBMCChatAPI;
import com.palmergames.bukkit.towny.TownyLogger;
import lombok.val;

View file

@ -4,9 +4,13 @@ import buttondevteam.chat.ChatPlayer;
import buttondevteam.chat.ChatProcessing;
import buttondevteam.chat.PluginMain;
import buttondevteam.chat.commands.ucmds.HistoryCommand;
import buttondevteam.component.channel.Channel;
import buttondevteam.component.channel.ChatChannelRegisterEvent;
import buttondevteam.component.channel.ChatRoom;
import buttondevteam.lib.TBMCChatEvent;
import buttondevteam.lib.TBMCCoreAPI;
import buttondevteam.lib.chat.*;
import buttondevteam.lib.chat.ChatMessage;
import buttondevteam.lib.chat.TBMCChatAPI;
import buttondevteam.lib.player.ChromaGamerBase;
import buttondevteam.lib.player.ChromaGamerBase.InfoTarget;
import buttondevteam.lib.player.TBMCPlayer;
@ -78,7 +82,7 @@ public class PlayerListener implements Listener {
int index = message.indexOf(" ");
val mp = ChromaGamerBase.getFromSender(sender);
String cmd;
final BiPredicate<Channel, String> checkchid = (chan, cmd1) -> cmd1.equalsIgnoreCase(chan.ID) || (chan.IDs != null && Arrays.stream(chan.IDs).anyMatch(cmd1::equalsIgnoreCase));
final BiPredicate<Channel, String> checkchid = (chan, cmd1) -> cmd1.equalsIgnoreCase(chan.ID) || (Arrays.stream(chan.IDs().get()).anyMatch(cmd1::equalsIgnoreCase));
if (index == -1) { // Only the command is run
if (!(sender instanceof Player || sender instanceof ConsoleCommandSender))
return false;
@ -96,7 +100,7 @@ public class PlayerListener implements Listener {
if (channel instanceof ChatRoom)
((ChatRoom) channel).joinRoom(sender);
}
sender.sendMessage("§6You are now talking in: §b" + mp.channel().get().DisplayName);
sender.sendMessage("§6You are now talking in: §b" + mp.channel().get().DisplayName().get());
return true;
}
}
@ -265,7 +269,7 @@ public class PlayerListener implements Listener {
for (Player p : Bukkit.getOnlinePlayers())
if (e.shouldSendTo(p))
p.sendMessage("§c!§r["
+ e.getChannel().DisplayName + "] <" + (e.getSender() instanceof Player
+ e.getChannel().DisplayName().get() + "] <" + (e.getSender() instanceof Player
? ((Player) e.getSender()).getDisplayName() : e.getSender().getName())
+ "> " + e.getMessage());
TBMCCoreAPI.SendException("An error occured while processing a chat message!", ex);

View file

@ -7,8 +7,8 @@ import buttondevteam.chat.formatting.TellrawEvent;
import buttondevteam.chat.formatting.TellrawEvent.ClickAction;
import buttondevteam.chat.formatting.TellrawEvent.HoverAction;
import buttondevteam.chat.formatting.TellrawPart;
import buttondevteam.component.channel.Channel;
import buttondevteam.core.TestPrepare;
import buttondevteam.lib.chat.Channel;
import buttondevteam.lib.chat.Color;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.command.CommandSender;