Fixes (/u ncolor), not allowing two of the same town colors, not broadcasting announcements if nobody is online #93
16 changed files with 577 additions and 397 deletions
19
.editorconfig
Normal file
19
.editorconfig
Normal file
|
@ -0,0 +1,19 @@
|
|||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
insert_final_newline = false
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
[*.json]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[*.java]
|
||||
indent_style = tab
|
||||
tab_width = 4
|
||||
|
||||
[{*.yml, *.yaml}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
36
Notes.txt
36
Notes.txt
|
@ -1,36 +0,0 @@
|
|||
Expected:
|
||||
|
||||
***test***
|
||||
||- ||-
|
||||
|
||||
||: bold
|
||||
-: italic
|
||||
|
||||
|
||||
Actual:
|
||||
|
||||
***test***
|
||||
||- ||-
|
||||
-|| -||
|
||||
- -
|
||||
|
||||
nextSection:
|
||||
*: italic(0)
|
||||
**:
|
||||
Either italic(0), bold(0) - Delete italic
|
||||
bold(0), italic(1) - Delete italic
|
||||
bold(0)
|
||||
Or bold(0), italic(0) - Delete italic?
|
||||
italic, italic - 0-length section as result, delete?
|
||||
|
||||
takenStart, takenEnd
|
||||
because it's ordered, the indexes will be either the same or ascending
|
||||
|
||||
|
||||
^^ Implemented
|
||||
|
||||
**test**
|
||||
^ ^ <-- !
|
||||
start end
|
||||
RemChar: 2
|
||||
tes*
|
1
lombok.config
Normal file
1
lombok.config
Normal file
|
@ -0,0 +1 @@
|
|||
lombok.var.flagUsage = ALLOW
|
42
pom.xml
42
pom.xml
|
@ -96,6 +96,46 @@
|
|||
</useSystemClassLoader> <!-- https://stackoverflow.com/a/53012553/2703239 -->
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- <plugin>
|
||||
<groupId>pl.project13.maven</groupId>
|
||||
<artifactId>git-commit-id-plugin</artifactId>
|
||||
<version>2.2.5</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>get-the-git-infos</id>
|
||||
<goals>
|
||||
<goal>revision</goal>
|
||||
</goals>
|
||||
*NOTE*: The default phase of revision is initialize, but in case you want to change it, you can do so by adding the phase here
|
||||
<phase>initialize</phase>
|
||||
<configuration>
|
||||
<injectAllReactorProjects>true</injectAllReactorProjects>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>validate-the-git-infos</id>
|
||||
<goals>
|
||||
<goal>validateRevision</goal>
|
||||
</goals>
|
||||
*NOTE*: The default phase of validateRevision is verify, but in case you want to change it, you can do so by adding the phase here
|
||||
<phase>package</phase>
|
||||
<configuration>
|
||||
<validationProperties>
|
||||
- <validationProperty>
|
||||
<name>validating git dirty</name>
|
||||
<value>${git.branch}</value>
|
||||
<shouldMatchTo>dev</shouldMatchTo>
|
||||
</validationProperty> -
|
||||
</validationProperties>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<injectAllReactorProjects>true</injectAllReactorProjects>
|
||||
<verbose>true</verbose>
|
||||
<dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
|
||||
</configuration>
|
||||
</plugin> -->
|
||||
<!-- <plugin> <groupId>org.basepom.maven</groupId> <artifactId>duplicate-finder-maven-plugin</artifactId>
|
||||
<version>1.2.1</version> <executions> <execution> <goals> <goal>check</goal>
|
||||
</goals> </execution> </executions> </plugin> -->
|
||||
|
@ -143,7 +183,7 @@
|
|||
<dependency>
|
||||
<groupId>com.github.TBMCPlugins.ButtonCore</groupId>
|
||||
<artifactId>ButtonCore</artifactId>
|
||||
<version>master-SNAPSHOT</version>
|
||||
<version>${env.TRAVIS_BRANCH}-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/net.sourceforge.htmlcleaner/htmlcleaner -->
|
||||
<dependency>
|
||||
|
|
|
@ -13,6 +13,7 @@ public class AnnouncerThread implements Runnable {
|
|||
} catch (InterruptedException ex) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
if (Bukkit.getOnlinePlayers().size() == 0) continue; //Don't post to Discord if nobody is on
|
||||
if (PluginMain.AnnounceMessages.size() > AnnounceMessageIndex) {
|
||||
Bukkit.broadcastMessage(PluginMain.AnnounceMessages.get(AnnounceMessageIndex));
|
||||
AnnounceMessageIndex++;
|
||||
|
|
|
@ -10,7 +10,10 @@ import buttondevteam.chat.listener.PlayerListener;
|
|||
import buttondevteam.lib.TBMCChatEvent;
|
||||
import buttondevteam.lib.TBMCChatEventBase;
|
||||
import buttondevteam.lib.TBMCCoreAPI;
|
||||
import buttondevteam.lib.chat.*;
|
||||
import buttondevteam.lib.chat.Channel;
|
||||
import buttondevteam.lib.chat.Color;
|
||||
import buttondevteam.lib.chat.Priority;
|
||||
import buttondevteam.lib.chat.TellrawSerializableEnum;
|
||||
import buttondevteam.lib.player.ChromaGamerBase;
|
||||
import buttondevteam.lib.player.TBMCPlayer;
|
||||
import buttondevteam.lib.player.TBMCPlayerBase;
|
||||
|
@ -37,7 +40,7 @@ public class ChatProcessing {
|
|||
private static final Pattern ESCAPE_PATTERN = Pattern.compile("\\\\");
|
||||
private static final Pattern CONSOLE_PING_PATTERN = Pattern.compile("(?i)" + Pattern.quote("@console"));
|
||||
private static final Pattern HASHTAG_PATTERN = Pattern.compile("#(\\w+)");
|
||||
private static final Pattern URL_PATTERN = Pattern.compile("(http[\\w:/?=$\\-_.+!*'(),]+)");
|
||||
private static final Pattern URL_PATTERN = Pattern.compile("(http[\\w:/?=$\\-_.+!*'(),&]+(?:#[\\w]+)?)");
|
||||
public static final Pattern ENTIRE_MESSAGE_PATTERN = Pattern.compile(".+");
|
||||
private static final Pattern UNDERLINED_PATTERN = Pattern.compile("_");
|
||||
private static final Pattern ITALIC_PATTERN = Pattern.compile("\\*");
|
||||
|
@ -84,6 +87,7 @@ public class ChatProcessing {
|
|||
.registerTypeAdapter(Boolean.class, new TellrawSerializer.TwBool())
|
||||
.registerTypeAdapter(boolean.class, new TellrawSerializer.TwBool()).disableHtmlEscaping().create();
|
||||
private static final String[] testPlayers = {"Koiiev", "iie", "Alisolarflare", "NorbiPeti", "Arsen_Derby_FTW", "carrot_lynx"};
|
||||
static final String MCORIGIN = "Minecraft"; //Shouldn't change, like ever - TBMCPlayer.getFolderForType(TBMCPlayer.class) capitalized
|
||||
|
||||
private ChatProcessing() {
|
||||
}
|
||||
|
@ -126,9 +130,9 @@ public class ChatProcessing {
|
|||
}).build());
|
||||
}
|
||||
pingedconsole = false; // Will set it to true onmatch (static constructor)
|
||||
final String channelidentifier = getChannelID(channel, sender);
|
||||
final String channelidentifier = getChannelID(channel, sender, e.getOrigin());
|
||||
|
||||
TellrawPart json = createTellraw(sender, message, player, mp, e.getUser(), channelidentifier);
|
||||
TellrawPart json = createTellraw(sender, message, player, mp, e.getUser(), channelidentifier, e.getOrigin());
|
||||
long combinetime = System.nanoTime();
|
||||
ChatFormatter.Combine(formatters, message, json);
|
||||
combinetime = System.nanoTime() - combinetime;
|
||||
|
@ -141,7 +145,7 @@ public class ChatProcessing {
|
|||
DebugCommand.SendDebugMessage(jsonstr);
|
||||
|
||||
try {
|
||||
if (channel.filteranderrormsg != null) {
|
||||
if (!channel.isGlobal()) {
|
||||
Objective obj = PluginMain.SB.getObjective(channel.ID);
|
||||
int score = -1;
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
|
@ -192,7 +196,8 @@ public class ChatProcessing {
|
|||
}
|
||||
|
||||
static TellrawPart createTellraw(CommandSender sender, String message, @Nullable Player player,
|
||||
@Nullable ChatPlayer mp, @Nullable ChromaGamerBase cg, final String channelidentifier) {
|
||||
@Nullable ChatPlayer mp, @Nullable ChromaGamerBase cg, final String channelidentifier,
|
||||
String origin) {
|
||||
TellrawPart json = new TellrawPart("");
|
||||
if (mp != null && mp.ChatOnly) {
|
||||
json.addExtra(new TellrawPart("[C]")
|
||||
|
@ -202,7 +207,7 @@ public class ChatProcessing {
|
|||
new TellrawPart(channelidentifier)
|
||||
.setHoverEvent(
|
||||
TellrawEvent.create(TellrawEvent.HoverAction.SHOW_TEXT,
|
||||
new TellrawPart((sender instanceof IDiscordSender ? "From Discord\n" : "")
|
||||
new TellrawPart((MCORIGIN.equals(origin) ? "" : "From " + origin + "n")
|
||||
+ "Copy message").setColor(Color.Blue)))
|
||||
.setClickEvent(TellrawEvent.create(TellrawEvent.ClickAction.SUGGEST_COMMAND, message)));
|
||||
if (PluginMain.permission.has(sender, "tbmc.badge.diamond"))
|
||||
|
@ -227,8 +232,8 @@ public class ChatProcessing {
|
|||
return player.getDisplayName();
|
||||
}
|
||||
|
||||
static String getChannelID(Channel channel, CommandSender sender) {
|
||||
return ("[" + (sender instanceof IDiscordSender ? "§8D§r|" : "") + channel.DisplayName)
|
||||
static String getChannelID(Channel channel, CommandSender sender, String origin) {
|
||||
return ("[" + (MCORIGIN.equals(origin) ? "" : "§8" + origin.substring(0, 1) + "§r|") + channel.DisplayName)
|
||||
+ "]";
|
||||
}
|
||||
|
||||
|
@ -252,19 +257,16 @@ public class ChatProcessing {
|
|||
namesb.append(")");
|
||||
StringBuilder nicksb = new StringBuilder("(?i)(");
|
||||
boolean addNickFormatter = false;
|
||||
final int size = Bukkit.getOnlinePlayers().size();
|
||||
int index = 0;
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
final String nick = PlayerListener.nicknames.inverse().get(p.getUniqueId());
|
||||
if (nick != null) {
|
||||
nicksb.append(nick);
|
||||
if (index < size - 1) {
|
||||
nicksb.append("|");
|
||||
addNickFormatter = true;
|
||||
}
|
||||
nicksb.append(nick).append("|");
|
||||
addNickFormatter = true; //Add it even if there's only 1 player online (it was in the if)
|
||||
}
|
||||
index++;
|
||||
}
|
||||
nicksb.deleteCharAt(nicksb.length() - 1);
|
||||
nicksb.append(")");
|
||||
|
||||
Consumer<String> error = message -> {
|
||||
|
|
|
@ -2,6 +2,7 @@ package buttondevteam.chat;
|
|||
|
||||
import buttondevteam.chat.commands.YeehawCommand;
|
||||
import buttondevteam.chat.commands.ucmds.TownColorCommand;
|
||||
import buttondevteam.chat.listener.PlayerJoinLeaveListener;
|
||||
import buttondevteam.chat.listener.PlayerListener;
|
||||
import buttondevteam.chat.listener.TownyListener;
|
||||
import buttondevteam.lib.TBMCCoreAPI;
|
||||
|
@ -81,6 +82,7 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15.
|
|||
PluginMain.essentials = (Essentials) (Bukkit.getPluginManager().getPlugin("Essentials"));
|
||||
|
||||
TBMCCoreAPI.RegisterEventsForExceptions(new PlayerListener(), this);
|
||||
TBMCCoreAPI.RegisterEventsForExceptions(new PlayerJoinLeaveListener(), this);
|
||||
TBMCCoreAPI.RegisterEventsForExceptions(new TownyListener(), this);
|
||||
TBMCChatAPI.AddCommands(this, YeehawCommand.class);
|
||||
Console = this.getServer().getConsoleSender();
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
package buttondevteam.chat.commands.ucmds;
|
||||
|
||||
import buttondevteam.lib.chat.Channel;
|
||||
import buttondevteam.lib.chat.ChatMessage;
|
||||
import buttondevteam.lib.chat.CommandClass;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.experimental.var;
|
||||
import lombok.val;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@CommandClass
|
||||
public class HistoryCommand extends UCommandBase {
|
||||
/**
|
||||
* Key: ChannelID_groupID
|
||||
*/
|
||||
private static HashMap<String, LinkedList<HistoryEntry>> messages = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public String[] GetHelpText(String alias) {
|
||||
return new String[]{ //
|
||||
"§6--- Chat History ----", //
|
||||
"Returns the last 10 messages the player can see." //
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
|
||||
return showHistory(sender, alias, args, this);
|
||||
}
|
||||
|
||||
public static boolean showHistory(CommandSender sender, String alias, String[] args, @Nullable HistoryCommand hc) {
|
||||
Function<Channel, LinkedList<HistoryEntry>> getThem = ch -> messages.get(ch.ID + "_" + ch.getGroupID(sender)); //If can't see, groupID is null, and that shouldn't be in the map
|
||||
sender.sendMessage("§6---- Chat History ----");
|
||||
Stream<Channel> stream;
|
||||
if (args.length == 0) {
|
||||
stream = Channel.getChannels().stream();
|
||||
} else {
|
||||
Optional<Channel> och = Channel.getChannels().stream().filter(chan -> chan.ID.equalsIgnoreCase(args[0])).findAny();
|
||||
if (!och.isPresent()) {
|
||||
sender.sendMessage("§cChannel not found. Use the ID, for example: /" + (hc == null ? "u history" : hc.GetCommandPath()) + " ooc");
|
||||
return true;
|
||||
}
|
||||
stream = Stream.of(och.get());
|
||||
}
|
||||
AtomicBoolean sent = new AtomicBoolean();
|
||||
val arr = stream.map(getThem).filter(Objects::nonNull).flatMap(Collection::stream)
|
||||
.sorted(Comparator.comparingLong(he -> he.timestamp)).toArray(HistoryEntry[]::new);
|
||||
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());
|
||||
sent.set(true);
|
||||
}
|
||||
if (!sent.get())
|
||||
sender.sendMessage("No messages can be found.");
|
||||
return true;
|
||||
}
|
||||
|
||||
@RequiredArgsConstructor
|
||||
private static class HistoryEntry {
|
||||
/**
|
||||
* System.nanoTime()
|
||||
*/
|
||||
private final long timestamp;
|
||||
private final ChatMessage chatMessage;
|
||||
private final Channel channel;
|
||||
}
|
||||
|
||||
public static void addChatMessage(ChatMessage chatMessage, Channel channel) {
|
||||
val groupID = channel.getGroupID(chatMessage.getPermCheck());
|
||||
if (groupID == null) return; //Just to be sure
|
||||
var ll = messages.computeIfAbsent(channel.ID + "_" + groupID, k -> new LinkedList<>()); //<-- TIL
|
||||
ll.add(new HistoryEntry(System.nanoTime(), chatMessage, channel)); //Adds as last element
|
||||
while (ll.size() > 10)
|
||||
ll.remove(); //Removes the first element
|
||||
}
|
||||
}
|
|
@ -58,16 +58,16 @@ public class NColorCommand extends UCommandBase {
|
|||
player.sendMessage("§cYour town doesn't have a color set. The town mayor can set it using /u towncolor.");
|
||||
return true;
|
||||
}
|
||||
if (nameparts.length < towncolors.length) {
|
||||
player.sendMessage("§cYou need more vertical lines (|) or colons (:) in your name. (Should have " + (towncolors.length - 1) + ")");
|
||||
if (nameparts.length < towncolors.length + 1) { //+1: Nation color
|
||||
player.sendMessage("§cYou need more vertical lines (|) or colons (:) in your name. (Should have " + (towncolors.length - 1 + 1) + ")"); //Nation color
|
||||
return true;
|
||||
}
|
||||
if (nameparts.length > towncolors.length * 2) {
|
||||
player.sendMessage("§cYou have waay too many vertical lines (|) or colons (:) in your name. (Should have " + (towncolors.length - 1) + ")");
|
||||
if (nameparts.length > (towncolors.length + 1) * 2) {
|
||||
player.sendMessage("§cYou have waay too many vertical lines (|) or colons (:) in your name. (Should have " + (towncolors.length - 1 + 1) + ")");
|
||||
return true;
|
||||
}
|
||||
if (nameparts.length > towncolors.length) {
|
||||
player.sendMessage("§cYou have too many vertical lines (|) or colons (:) in your name. (Should have " + (towncolors.length - 1) + ")");
|
||||
if (nameparts.length > towncolors.length + 1) {
|
||||
player.sendMessage("§cYou have too many vertical lines (|) or colons (:) in your name. (Should have " + (towncolors.length - 1 + 1) + ")");
|
||||
return true;
|
||||
}
|
||||
ChatPlayer.getPlayer(player.getUniqueId(), ChatPlayer.class).NameColorLocations()
|
||||
|
|
|
@ -2,6 +2,7 @@ package buttondevteam.chat.commands.ucmds.admin;
|
|||
|
||||
import buttondevteam.chat.PluginMain;
|
||||
import buttondevteam.chat.listener.TownyListener;
|
||||
import buttondevteam.lib.chat.Color;
|
||||
import com.palmergames.bukkit.towny.object.Nation;
|
||||
import com.palmergames.bukkit.towny.object.Town;
|
||||
import lombok.val;
|
||||
|
@ -37,6 +38,14 @@ public class NationColorCommand extends AdminCommandBase {
|
|||
}
|
||||
val c = TownColorCommand.getColorOrSendError(args[1], sender);
|
||||
if (!c.isPresent()) return true;
|
||||
if (!c.get().getName().equals(Color.White.getName())) { //Default nation color
|
||||
for (val nc : PluginMain.NationColor.values()) {
|
||||
if (nc.getName().equals(c.get().getName())) {
|
||||
sender.sendMessage("§cAnother nation already uses this color!");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
PluginMain.NationColor.put(args[0].toLowerCase(), c.get());
|
||||
Bukkit.getScheduler().runTaskAsynchronously(PluginMain.Instance, () -> {
|
||||
for (Town t : nation.getTowns())
|
||||
|
|
|
@ -10,6 +10,7 @@ import org.bukkit.command.CommandSender;
|
|||
import org.dynmap.towny.DynmapTownyPlugin;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -46,6 +47,33 @@ public class TownColorCommand extends AdminCommandBase {
|
|||
return true;
|
||||
clrs[i - 1] = c.get();
|
||||
}
|
||||
for (Map.Entry<String, Color[]> other : PluginMain.TownColors.entrySet()) {
|
||||
Color nc, tnc;
|
||||
try {
|
||||
nc = PluginMain.NationColor.get(PluginMain.TU.getTownsMap().get(other.getKey()).getNation().getName().toLowerCase());
|
||||
} catch (Exception e) { //Too lazy for lots of null-checks and it may throw exceptions anyways
|
||||
nc = null;
|
||||
}
|
||||
if (nc == null) nc = Color.White; //Default nation color
|
||||
try {
|
||||
tnc = PluginMain.NationColor.get(targetTown.getNation().getName().toLowerCase());
|
||||
} catch (Exception e) {
|
||||
tnc = null;
|
||||
}
|
||||
if (tnc == null) tnc = Color.White; //Default nation color - TODO: Make configurable
|
||||
if (nc.getName().equals(tnc.getName())) {
|
||||
int C = 0;
|
||||
if (clrs.length == other.getValue().length)
|
||||
for (int i = 0; i < clrs.length; i++)
|
||||
if (clrs[i].getName().equals(other.getValue()[i].getName()))
|
||||
C++;
|
||||
else break;
|
||||
if (C == clrs.length) {
|
||||
sender.sendMessage("§cThis town color combination is already used!");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
PluginMain.TownColors.put(args[0].toLowerCase(), clrs);
|
||||
TownyListener.updateTownMembers(targetTown);
|
||||
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
package buttondevteam.chat.commands.ucmds.admin;
|
||||
|
||||
import buttondevteam.chat.PluginMain;
|
||||
import buttondevteam.component.updater.PluginUpdater;
|
||||
import buttondevteam.lib.TBMCCoreAPI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import buttondevteam.chat.PluginMain;
|
||||
import buttondevteam.lib.PluginUpdater;
|
||||
import buttondevteam.lib.TBMCCoreAPI;
|
||||
|
||||
public class UpdatePlugin extends AdminCommandBase {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package buttondevteam.chat.components;
|
||||
|
||||
import buttondevteam.lib.architecture.Component;
|
||||
import buttondevteam.lib.architecture.ConfigData;
|
||||
|
||||
public class TownColorComponent extends Component {
|
||||
public ConfigData<Byte> colorCount() { //TODO
|
||||
return getData("colorCount", (byte) 1, cc -> (byte) cc, cc -> (int) cc);
|
||||
}
|
||||
|
||||
public ConfigData<Boolean> useNationColors() { //TODO
|
||||
return getData("useNationColors", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void enable() {
|
||||
//TODO: Don't register all commands automatically (welp)
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void disable() {
|
||||
|
||||
}
|
||||
}
|
|
@ -5,6 +5,7 @@ import buttondevteam.chat.FlairStates;
|
|||
import buttondevteam.chat.PlayerJoinTimerTask;
|
||||
import buttondevteam.chat.PluginMain;
|
||||
import buttondevteam.chat.commands.UnlolCommand;
|
||||
import buttondevteam.chat.commands.ucmds.HistoryCommand;
|
||||
import buttondevteam.lib.chat.Color;
|
||||
import buttondevteam.lib.player.TBMCPlayerJoinEvent;
|
||||
import buttondevteam.lib.player.TBMCPlayerLoadEvent;
|
||||
|
@ -64,14 +65,14 @@ public class PlayerJoinLeaveListener implements Listener {
|
|||
nwithoutformatting = p.getName();
|
||||
PlayerListener.nicknames.forcePut(nwithoutformatting.toLowerCase(), p.getUniqueId());
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(PluginMain.Instance, () -> {
|
||||
updatePlayerColors(p, cp); //TODO: Doesn't have effect
|
||||
}, 5);
|
||||
updatePlayerColors(p, cp); //TO!DO: Doesn't have effect - It can help to register the listener
|
||||
|
||||
if (cp.ChatOnly || p.getGameMode().equals(GameMode.SPECTATOR)) {
|
||||
cp.ChatOnly = false;
|
||||
p.setGameMode(GameMode.SURVIVAL);
|
||||
}
|
||||
|
||||
HistoryCommand.showHistory(e.getPlayer(), "u history", new String[0], null);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
|
|
@ -3,6 +3,7 @@ package buttondevteam.chat.listener;
|
|||
import buttondevteam.chat.ChatPlayer;
|
||||
import buttondevteam.chat.ChatProcessing;
|
||||
import buttondevteam.chat.PluginMain;
|
||||
import buttondevteam.chat.commands.ucmds.HistoryCommand;
|
||||
import buttondevteam.lib.TBMCChatEvent;
|
||||
import buttondevteam.lib.TBMCCoreAPI;
|
||||
import buttondevteam.lib.chat.*;
|
||||
|
@ -258,6 +259,7 @@ public class PlayerListener implements Listener {
|
|||
try {
|
||||
if (e.isCancelled())
|
||||
return;
|
||||
HistoryCommand.addChatMessage(e.getCm(), e.getChannel());
|
||||
e.setCancelled(ChatProcessing.ProcessChat(e));
|
||||
} catch (NoClassDefFoundError | Exception ex) { // Weird things can happen
|
||||
for (Player p : Bukkit.getOnlinePlayers())
|
||||
|
@ -272,7 +274,7 @@ public class PlayerListener implements Listener {
|
|||
|
||||
@EventHandler
|
||||
public void onChannelRegistered(ChatChannelRegisterEvent e) {
|
||||
if (e.getChannel().filteranderrormsg != null && PluginMain.SB.getObjective(e.getChannel().ID) == null) // Not global chat and doesn't exist yet
|
||||
if (!e.getChannel().isGlobal() && PluginMain.SB.getObjective(e.getChannel().ID) == null) // Not global chat and doesn't exist yet
|
||||
PluginMain.SB.registerNewObjective(e.getChannel().ID, "dummy");
|
||||
}
|
||||
|
||||
|
|
|
@ -65,6 +65,11 @@ public class ChatFormatIT {
|
|||
.setClickEvent(TellrawEvent.create(ClickAction.OPEN_URL, "https://norbipeti.github.io/")), new TellrawPart(" heh").setItalic(true)));
|
||||
list.add(new ChatFormatIT(sender, "*test _test_ test*", new TellrawPart("test ").setItalic(true).setColor(Color.White),
|
||||
new TellrawPart("test").setItalic(true).setUnderlined(true).setColor(Color.White), new TellrawPart(" test").setItalic(true).setColor(Color.White)));
|
||||
list.add(new ChatFormatIT(sender, "https://norbipeti.github.io/test?test&test#test", new TellrawPart("https://norbipeti.github.io/test?test&test#test")
|
||||
.setColor(Color.White).setUnderlined(true)
|
||||
.setHoverEvent(TellrawEvent.create(HoverAction.SHOW_TEXT,
|
||||
new TellrawPart("Click to open").setColor(Color.Blue)))
|
||||
.setClickEvent(TellrawEvent.create(ClickAction.OPEN_URL, "https://norbipeti.github.io/test?test&test#test"))));
|
||||
|
||||
return list;
|
||||
}
|
||||
|
@ -82,12 +87,12 @@ public class ChatFormatIT {
|
|||
@Test
|
||||
public void testMessage() {
|
||||
ArrayList<ChatFormatter> cfs = ChatProcessing.addFormatters(Color.White);
|
||||
final String chid = ChatProcessing.getChannelID(Channel.GlobalChat, sender);
|
||||
final TellrawPart tp = ChatProcessing.createTellraw(sender, message, null, null, null, chid);
|
||||
final String chid = ChatProcessing.getChannelID(Channel.GlobalChat, sender, ChatProcessing.MCORIGIN);
|
||||
final TellrawPart tp = ChatProcessing.createTellraw(sender, message, null, null, null, chid, ChatProcessing.MCORIGIN);
|
||||
ChatFormatter.Combine(cfs, message, tp);
|
||||
System.out.println("Testing: " + message);
|
||||
// System.out.println(ChatProcessing.toJson(tp));
|
||||
final TellrawPart expectedtp = ChatProcessing.createTellraw(sender, message, null, null, null, chid);
|
||||
final TellrawPart expectedtp = ChatProcessing.createTellraw(sender, message, null, null, null, chid, ChatProcessing.MCORIGIN);
|
||||
// System.out.println("Raw: " + ChatProcessing.toJson(expectedtp));
|
||||
for (TellrawPart extra : extras)
|
||||
expectedtp.addExtra(extra);
|
||||
|
|
Loading…
Reference in a new issue