1.14 support, fixes #105
6 changed files with 86 additions and 37 deletions
|
@ -39,5 +39,41 @@
|
|||
<orderEntry type="library" name="Maven: org.anjocaido:EssentialsGroupManager:2.10.1" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.guava:guava:21.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.19" level="project" />
|
||||
<orderEntry type="library" name="Maven: net.md-5:bungeecord-chat:1.12-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.TBMCPlugins.ButtonCore:ButtonCore:master-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" name="Maven: net.sourceforge.htmlcleaner:htmlcleaner:2.16" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jdom:jdom2:2.0.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.reflections:reflections:0.9.10" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.javassist:javassist:3.19.0-GA" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.code.findbugs:annotations:2.0.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:EssentialsX:2.17.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: io.papermc:paperlib:1.0.2" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:NMSProvider:2.17.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:UpdatedMetaProvider:2.17.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:1_8_R1Provider:2.17.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:1_8_R2Provider:2.17.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:LegacyProvider:2.17.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:ReflectionProvider:2.17.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:FlattenedProvider:2.17.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.TBMCPlugins.ButtonCore:Towny:8d3b6b6" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.milkbowl:VaultAPI:master-af0353b1d7-1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.bukkit:bukkit:1.13.1-R0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.projectlombok:lombok:1.16.16" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot:1.12.2-R0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.webbukkit:Dynmap-Towny:master-0.60-g924051d-7" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.webbukkit:Dynmap:v2.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.nijikokun.bukkit:Permissions:3.1.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: ru.tehkode:PermissionsEx:1.19.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: de.bananaco:bPermissions:2.9.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.platymuus.bukkit.permissions:PermissionsBukkit:1.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.anjocaido:EssentialsGroupManager:2.10.1" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
|
||||
</component>
|
||||
</module>
|
19
pom.xml
19
pom.xml
|
@ -151,10 +151,10 @@
|
|||
<id>jitpack</id>
|
||||
<url>https://jitpack.io/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>Essentials</id>
|
||||
<url>http://repo.ess3.net/content/repositories/essrel/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>ess-repo</id>
|
||||
<url>https://ci.ender.zone/plugin/repository/everything/</url>
|
||||
</repository>
|
||||
<!-- <repository>
|
||||
<id>Minigames</id>
|
||||
<url>http://maven.addstar.com.au/artifactory/release</url>
|
||||
|
@ -193,11 +193,12 @@
|
|||
<artifactId>reflections</artifactId>
|
||||
<version>0.9.10</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ess3</groupId>
|
||||
<artifactId>Essentials</artifactId>
|
||||
<version>2.13.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ess3</groupId>
|
||||
<artifactId>EssentialsX</artifactId>
|
||||
<version>2.17.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.TBMCPlugins.ButtonCore</groupId>
|
||||
<artifactId>Towny</artifactId>
|
||||
|
|
|
@ -34,6 +34,7 @@ import javax.annotation.Nullable;
|
|||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class ChatProcessing {
|
||||
|
@ -140,7 +141,7 @@ public class ChatProcessing {
|
|||
colormode = Color.Green;
|
||||
// If greentext, ignore channel or player colors
|
||||
|
||||
ArrayList<ChatFormatter> formatters = addFormatters(colormode);
|
||||
ArrayList<ChatFormatter> formatters = addFormatters(colormode, e::shouldSendTo);
|
||||
if (colormode == channel.Color().get() && mp != null && mp.RainbowPresserColorMode) { // Only overwrite channel color
|
||||
final AtomicInteger rpc = new AtomicInteger(0);
|
||||
formatters.add(ChatFormatter.builder().regex(WORD_PATTERN).color(colormode).onmatch((match, cf, s) -> {
|
||||
|
@ -240,7 +241,7 @@ public class ChatProcessing {
|
|||
+ "]";
|
||||
}
|
||||
|
||||
static ArrayList<ChatFormatter> addFormatters(Color colormode) {
|
||||
static ArrayList<ChatFormatter> addFormatters(Color colormode, Predicate<Player> canSee) {
|
||||
@SuppressWarnings("unchecked")
|
||||
ArrayList<ChatFormatter> formatters = (ArrayList<ChatFormatter>) commonFormatters.clone();
|
||||
|
||||
|
@ -250,12 +251,19 @@ public class ChatProcessing {
|
|||
boolean nottest; //Not assigning a default value, so that it can only be used in the if
|
||||
if ((nottest = Bukkit.getOnlinePlayers().size() > 0) || Bukkit.getVersion().equals("test")) {
|
||||
StringBuilder namesb = new StringBuilder("(?i)(");
|
||||
boolean addNameFormatter = false; //Needed because some names may be filtered out if they can't see the channel
|
||||
if (nottest)
|
||||
for (Player p : Bukkit.getOnlinePlayers())
|
||||
namesb.append(p.getName()).append("|");
|
||||
else
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
if (canSee.test(p)) {
|
||||
namesb.append(p.getName()).append("|");
|
||||
addNameFormatter = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (String testPlayer : testPlayers)
|
||||
namesb.append(testPlayer).append("|");
|
||||
addNameFormatter = true;
|
||||
}
|
||||
namesb.deleteCharAt(namesb.length() - 1);
|
||||
namesb.append(")");
|
||||
StringBuilder nicksb = new StringBuilder("(?i)(");
|
||||
|
@ -264,7 +272,7 @@ public class ChatProcessing {
|
|||
final String nick = PlayerListener.nicknames.inverse().get(p.getUniqueId());
|
||||
if (nick != null) {
|
||||
nicksb.append(nick).append("|");
|
||||
addNickFormatter = true; //Add it even if there's only 1 player online (it was in the if)
|
||||
addNickFormatter = true;
|
||||
}
|
||||
}
|
||||
nicksb.deleteCharAt(nicksb.length() - 1);
|
||||
|
@ -277,22 +285,23 @@ public class ChatProcessing {
|
|||
System.out.println(message);
|
||||
};
|
||||
|
||||
formatters.add(ChatFormatter.builder().regex(Pattern.compile(namesb.toString())).color(Color.Aqua)
|
||||
.onmatch((match, builder, section) -> {
|
||||
Player p = Bukkit.getPlayer(match);
|
||||
Optional<String> pn = nottest ? Optional.empty()
|
||||
: Arrays.stream(testPlayers).filter(tp -> tp.equalsIgnoreCase(match)).findAny();
|
||||
if (nottest ? p == null : !pn.isPresent()) {
|
||||
error.accept("Error: Can't find player " + match + " but was reported as online.");
|
||||
return "§c" + match + "§r";
|
||||
}
|
||||
ChatPlayer mpp = TBMCPlayer.getPlayer(nottest ? p.getUniqueId() : new UUID(0, 0), ChatPlayer.class);
|
||||
if (nottest) {
|
||||
playPingSound(p);
|
||||
}
|
||||
String color = String.format("§%x", (mpp.GetFlairColor() == 0x00 ? 0xb : mpp.GetFlairColor()));
|
||||
return color + (nottest ? p.getName() : pn.get()) + "§r"; //Fix name casing, except when testing
|
||||
}).priority(Priority.High).type(ChatFormatter.Type.Excluder).build());
|
||||
if (addNameFormatter)
|
||||
formatters.add(ChatFormatter.builder().regex(Pattern.compile(namesb.toString())).color(Color.Aqua)
|
||||
.onmatch((match, builder, section) -> {
|
||||
Player p = Bukkit.getPlayer(match);
|
||||
Optional<String> pn = nottest ? Optional.empty()
|
||||
: Arrays.stream(testPlayers).filter(tp -> tp.equalsIgnoreCase(match)).findAny();
|
||||
if (nottest ? p == null : !pn.isPresent()) {
|
||||
error.accept("Error: Can't find player " + match + " but was reported as online.");
|
||||
return "§c" + match + "§r";
|
||||
}
|
||||
ChatPlayer mpp = TBMCPlayer.getPlayer(nottest ? p.getUniqueId() : new UUID(0, 0), ChatPlayer.class);
|
||||
if (nottest) {
|
||||
playPingSound(p);
|
||||
}
|
||||
String color = String.format("§%x", (mpp.GetFlairColor() == 0x00 ? 0xb : mpp.GetFlairColor()));
|
||||
return color + (nottest ? p.getName() : pn.get()) + "§r"; //Fix name casing, except when testing
|
||||
}).priority(Priority.High).type(ChatFormatter.Type.Excluder).build());
|
||||
|
||||
if (addNickFormatter)
|
||||
formatters.add(ChatFormatter.builder().regex((Pattern.compile(nicksb.toString()))).color(Color.Aqua)
|
||||
|
|
|
@ -6,6 +6,8 @@ import buttondevteam.lib.chat.*;
|
|||
import buttondevteam.lib.player.TBMCPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@CommandClass(path = "u c", helpText = {
|
||||
"Rainbow mode",
|
||||
"This command allows you to talk in rainbow colors"
|
||||
|
@ -32,7 +34,8 @@ public class CCommand extends ICommand2MC {
|
|||
p.RainbowPresserColorMode = false;
|
||||
p.OtherColorMode = null;
|
||||
try {
|
||||
p.OtherColorMode = Color.valueOf(color.toLowerCase());
|
||||
String x = color.toLowerCase();
|
||||
p.OtherColorMode = Arrays.stream(Color.values()).filter(c -> c.getName().equals(x)).findAny().orElse(null);
|
||||
} catch (Exception e) {
|
||||
player.sendMessage("§cUnknown message color: " + color);
|
||||
player.sendMessage("§cUse color names, like blue, or dark_aqua");
|
||||
|
|
|
@ -141,13 +141,13 @@ public class FunComponent extends Component<PluginMain> implements Listener {
|
|||
}
|
||||
if (PluginMain.permission.has(event.getSender(), "thorpe.unanything")) {
|
||||
event.setCancelled(true);
|
||||
String s = cmd.substring(3);
|
||||
int index = event.getMessage().indexOf(' ');
|
||||
int index = cmd.lastIndexOf(' ');
|
||||
if (index == -1) {
|
||||
event.getSender().sendMessage("§cUsage: /un" + s + " <player>");
|
||||
event.getSender().sendMessage("§cUsage: " + cmd + " <player>");
|
||||
return;
|
||||
}
|
||||
Player target = Bukkit.getPlayer(event.getMessage().substring(index + 1));
|
||||
String s = cmd.substring(3, index);
|
||||
Player target = Bukkit.getPlayer(cmd.substring(index + 1));
|
||||
if (target == null) {
|
||||
event.getSender().sendMessage("§cError: Player not found. (/un" + s + " <player>)");
|
||||
return;
|
||||
|
|
|
@ -91,7 +91,7 @@ public class ChatFormatIT {
|
|||
|
||||
@Test
|
||||
public void testMessage() {
|
||||
ArrayList<ChatFormatter> cfs = ChatProcessing.addFormatters(Color.White);
|
||||
ArrayList<ChatFormatter> cfs = ChatProcessing.addFormatters(Color.White, p -> true);
|
||||
final String chid = ChatProcessing.getChannelID(Channel.GlobalChat, ChatProcessing.MCORIGIN);
|
||||
final TellrawPart tp = ChatProcessing.createTellraw(sender, message, null, null, null, chid, ChatProcessing.MCORIGIN);
|
||||
ChatFormatter.Combine(cfs, message, tp);
|
||||
|
|
Loading…
Reference in a new issue