Skip to content

Commit

Permalink
Merge pull request #98 from TBMCPlugins/dev
Browse files Browse the repository at this point in the history
More components, broadcasts
  • Loading branch information
NorbiPeti authored Mar 17, 2019
2 parents e2a6afd + c7f04b8 commit c25097b
Show file tree
Hide file tree
Showing 58 changed files with 1,209 additions and 1,274 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ pip-log.txt
.mr.developer.cfg
.metadata/*
TheButtonAutoFlair/out/artifacts/Autoflair/Autoflair.jar
*.iml
#*.iml
*.name
.idea/compiler.xml
*.xml
Expand Down
71 changes: 71 additions & 0 deletions .idea/ButtonChat.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 4 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -155,18 +155,14 @@
<id>Essentials</id>
<url>http://repo.ess3.net/content/repositories/essrel/</url>
</repository>
<repository>
<id>Votifier</id>
<url>https://dl.bintray.com/nuvotifier/maven/</url>
</repository>
<repository>
<id>Minigames</id>
<url>http://maven.addstar.com.au/artifactory/release</url>
</repository>
<repository>
<!-- <repository>
<id>vault-repo</id>
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
</repository>
</repository> -->
<!-- <repository> <id>WorldEdit</id> <url>http://maven.sk89q.com/artifactory/repo</url>
</repository> -->
<repository>
Expand Down Expand Up @@ -207,17 +203,12 @@
<artifactId>Towny</artifactId>
<version>8d3b6b6</version>
</dependency>
<dependency>
<groupId>com.vexsoftware</groupId>
<artifactId>nuvotifier-universal</artifactId>
<version>2.3.4</version>
</dependency>
<!-- <dependency> <groupId>au.com.mineauz</groupId> <artifactId>Minigames</artifactId>
<version>1.8.0</version> </dependency> -->
<dependency>
<groupId>net.milkbowl.vault</groupId>
<groupId>com.github.milkbowl</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.6</version>
<version>master-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
78 changes: 29 additions & 49 deletions src/main/java/buttondevteam/chat/ChatProcessing.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package buttondevteam.chat;

import buttondevteam.chat.commands.UnlolCommand;
import buttondevteam.chat.commands.ucmds.admin.DebugCommand;
import buttondevteam.chat.components.chatonly.ChatOnlyComponent;
import buttondevteam.chat.components.fun.FunComponent;
import buttondevteam.chat.components.towny.TownyComponent;
import buttondevteam.chat.formatting.ChatFormatter;
import buttondevteam.chat.formatting.TellrawEvent;
import buttondevteam.chat.formatting.TellrawPart;
import buttondevteam.chat.formatting.TellrawSerializer;
import buttondevteam.chat.listener.PlayerListener;
import buttondevteam.core.ComponentManager;
import buttondevteam.core.component.channel.Channel;
import buttondevteam.lib.TBMCChatEvent;
import buttondevteam.lib.TBMCChatEventBase;
Expand Down Expand Up @@ -52,7 +55,8 @@ public class ChatProcessing {
private static final Pattern SPOILER_PATTERN = Pattern.compile("\\|\\|");
private static final Color[] RainbowPresserColors = new Color[]{Color.Red, Color.Gold, Color.Yellow, Color.Green,
Color.Blue, Color.DarkPurple};
private static boolean pingedconsole = false;
private static final Pattern WORD_PATTERN = Pattern.compile("\\S+");
private static boolean pingedconsole = false;

public static final ChatFormatter ESCAPE_FORMATTER = ChatFormatter.builder().regex(ESCAPE_PATTERN).build();

Expand Down Expand Up @@ -134,13 +138,13 @@ public static boolean ProcessChat(TBMCChatEvent e) {
ArrayList<ChatFormatter> formatters = addFormatters(colormode);
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, s) -> {
formatters.add(ChatFormatter.builder().regex(WORD_PATTERN).color(colormode).onmatch((match, cf, s) -> {
cf.setColor(RainbowPresserColors[rpc.getAndUpdate(i -> ++i < RainbowPresserColors.length ? i : 0)]);
return match;
}).build());
}
pingedconsole = false; // Will set it to true onmatch (static constructor)
final String channelidentifier = getChannelID(channel, sender, e.getOrigin());
final String channelidentifier = getChannelID(channel, e.getOrigin());

TellrawPart json = createTellraw(sender, message, player, mp, e.getUser(), channelidentifier, e.getOrigin());
long combinetime = System.nanoTime();
Expand Down Expand Up @@ -174,16 +178,11 @@ public static boolean ProcessChat(TBMCChatEvent e) {
if (score < 0) // Never send messages to score below 0
sender.sendMessage("§cYou don't have permission to send this message or something went wrong");
else {
PluginMain.Instance.getServer().dispatchCommand(PluginMain.Console,
String.format("tellraw @a[score_%s=%d,score_%s_min=%d] %s", channel.ID, score, channel.ID,
score, jsonstr));
if (e.getChannel().ID.equals(PluginMain.TownChat.ID)
|| e.getChannel().ID.equals(PluginMain.NationChat.ID)) {
((List<TellrawPart>) json.getExtra()).add(0, new TellrawPart("[SPY]"));
jsonstr = toJson(json);
Bukkit.getServer().dispatchCommand(PluginMain.Console, String.format(
"tellraw @a[score_%s=1000,score_%s_min=1000] %s", channel.ID, channel.ID, jsonstr));
}
PluginMain.Instance.getServer().dispatchCommand(PluginMain.Console,
String.format("tellraw @a[score_%s=%d,score_%s_min=%d] %s", channel.ID, score, channel.ID,
score, jsonstr));
val tc = ComponentManager.getIfEnabled(TownyComponent.class);
if (tc != null) tc.handleSpies(channel, json, ChatProcessing::toJson);
}
} else
PluginMain.Instance.getServer().dispatchCommand(PluginMain.Console,
Expand All @@ -209,10 +208,7 @@ static TellrawPart createTellraw(CommandSender sender, String message, @Nullable
@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]")
.setHoverEvent(TellrawEvent.create(TellrawEvent.HoverAction.SHOW_TEXT, "Chat only")));
}
ChatOnlyComponent.tellrawCreate(mp, json); //TODO: Make nice API
json.addExtra(
new TellrawPart(channelidentifier)
.setHoverEvent(
Expand Down Expand Up @@ -242,7 +238,7 @@ private static String getSenderName(CommandSender sender, Player player) {
return player.getDisplayName();
}

static String getChannelID(Channel channel, CommandSender sender, String origin) {
static String getChannelID(Channel channel, String origin) {
return ("[" + (MCORIGIN.equals(origin) ? "" : "§8" + origin.substring(0, 1) + "§r|") + channel.DisplayName().get())
+ "]";
}
Expand Down Expand Up @@ -295,12 +291,8 @@ static ArrayList<ChatFormatter> addFormatters(Color colormode) {
}
ChatPlayer mpp = TBMCPlayer.getPlayer(nottest ? p.getUniqueId() : new UUID(0, 0), ChatPlayer.class);
if (nottest) {
if (PluginMain.Instance.notificationSound().get().length() == 0)
p.playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1.0f, 0.5f); // TODO: Airhorn
else
p.playSound(p.getLocation(), PluginMain.Instance.notificationSound().get(), 1.0f,
PluginMain.Instance.notificationPitch().get());
}
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());
Expand All @@ -315,12 +307,8 @@ static ArrayList<ChatFormatter> addFormatters(Color colormode) {
+ match.toLowerCase() + " but was reported as online.");
return "§c" + match + "§r";
}
if (PluginMain.Instance.notificationSound().get().length() == 0)
p.playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1.0f, 0.5f); // TODO: Airhorn
else
p.playSound(p.getLocation(), PluginMain.Instance.notificationSound().get(), 1.0f,
PluginMain.Instance.notificationPitch().get());
return PluginMain.essentials.getUser(p).getNickname();
playPingSound(p);
return PluginMain.essentials.getUser(p).getNickname();
}
error.accept("Player nicknamed " + match.toLowerCase()
+ " not found in nickname map but was reported as online.");
Expand All @@ -330,24 +318,16 @@ static ArrayList<ChatFormatter> addFormatters(Color colormode) {
return formatters;
}

static void doFunStuff(CommandSender sender, TBMCChatEventBase event, String message) {
if (PlayerListener.ActiveF && !PlayerListener.Fs.contains(sender) && message.equalsIgnoreCase("F"))
PlayerListener.Fs.add(sender);
private static void playPingSound(Player p) {
if (PluginMain.Instance.notificationSound().get().length() == 0)
p.playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1.0f, 0.5f); // TODO: Airhorn
else
p.playSound(p.getLocation(), PluginMain.Instance.notificationSound().get(), 1.0f,
PluginMain.Instance.notificationPitch().get());
}

String msg = message.toLowerCase();
val lld = new UnlolCommand.LastlolData(sender, event, System.nanoTime());
boolean add;
if (add = msg.contains("lol"))
lld.setLolornot(true);
else {
for (int i = 0; i < PlayerListener.LaughStrings.length; i++) {
if (add = msg.contains(PlayerListener.LaughStrings[i])) {
lld.setLolornot(false);
break;
}
}
}
if (add)
UnlolCommand.Lastlol.put(event.getChannel(), lld);
static void doFunStuff(CommandSender sender, TBMCChatEventBase event, String message) {
val fc=ComponentManager.getIfEnabled(FunComponent.class);
if(fc!=null) fc.onChat(sender, event, message);
}
}
Loading

0 comments on commit c25097b

Please sign in to comment.