Fixes (/u ncolor), not allowing two of the same town colors, not broadcasting announcements if nobody is online #93

Merged
NorbiPeti merged 10 commits from dev into master 2019-01-03 20:43:22 +00:00
5 changed files with 59 additions and 51 deletions
Showing only changes of commit 6da19877b8 - Show all commits

View file

@ -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*

42
pom.xml
View file

@ -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>

View file

@ -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;
@ -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;
@ -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)
+ "]";
}

View file

@ -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

View file

@ -82,12 +82,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);