Update Chroma-Core to v2.0.0
This commit is contained in:
parent
6c1378f370
commit
522f29ba58
21 changed files with 55 additions and 44 deletions
9
pom.xml
9
pom.xml
|
@ -125,7 +125,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.TBMCPlugins.ChromaCore</groupId>
|
<groupId>com.github.TBMCPlugins.ChromaCore</groupId>
|
||||||
<artifactId>Chroma-Core</artifactId>
|
<artifactId>Chroma-Core</artifactId>
|
||||||
<version>v1.0.0</version>
|
<version>v2.0.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.essentialsx</groupId>
|
<groupId>net.essentialsx</groupId>
|
||||||
|
@ -198,6 +198,13 @@
|
||||||
<version>4.2.0</version>
|
<version>4.2.0</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- https://mvnrepository.com/artifact/com.mojang/brigadier -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mojang</groupId>
|
||||||
|
<artifactId>brigadier</artifactId>
|
||||||
|
<version>1.0.500</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<artifactId>Chroma-Chat</artifactId>
|
<artifactId>Chroma-Chat</artifactId>
|
||||||
<organization>
|
<organization>
|
||||||
|
|
|
@ -9,11 +9,13 @@ import buttondevteam.lib.player.TBMCPlayerBase;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
@PlayerClass(pluginname = "Chroma-Chat")
|
@PlayerClass(pluginname = "Chroma-Chat")
|
||||||
public class ChatPlayer extends TBMCPlayerBase {
|
public class ChatPlayer extends TBMCPlayerBase {
|
||||||
public final ConfigData<String> UserName = getConfig().getData("UserName", "");
|
public final ConfigData<String> UserName = getConfig().getData("UserName", "");
|
||||||
|
|
||||||
public final ListConfigData<String> UserNames = getConfig().getListData("UserNames");
|
public final ListConfigData<String> UserNames = getConfig().getListData("UserNames", Collections.emptyList());
|
||||||
|
|
||||||
public final ConfigData<Integer> FlairTime = getConfig().getData("FlairTime", FlairTimeNone);
|
public final ConfigData<Integer> FlairTime = getConfig().getData("FlairTime", FlairTimeNone);
|
||||||
|
|
||||||
|
@ -26,7 +28,7 @@ public class ChatPlayer extends TBMCPlayerBase {
|
||||||
|
|
||||||
public final ConfigData<Boolean> FlairCheater = getConfig().getData("FlairCheater", false);
|
public final ConfigData<Boolean> FlairCheater = getConfig().getData("FlairCheater", false);
|
||||||
|
|
||||||
public final ListConfigData<Integer> NameColorLocations = getConfig().getListData("NameColorLocations"); // No byte[], no TIntArrayList
|
public final ListConfigData<Integer> NameColorLocations = getConfig().getListData("NameColorLocations", Collections.emptyList()); // No byte[], no TIntArrayList
|
||||||
|
|
||||||
public boolean Working;
|
public boolean Working;
|
||||||
// public int Tables = 10;
|
// public int Tables = 10;
|
||||||
|
@ -80,7 +82,7 @@ public class ChatPlayer extends TBMCPlayerBase {
|
||||||
|
|
||||||
// Flairs from Command Block The Button - Teams
|
// Flairs from Command Block The Button - Teams
|
||||||
// PluginMain.Instance.getServer().getScoreboardManager().getMainScoreboard().getTeams().add()
|
// PluginMain.Instance.getServer().getScoreboardManager().getMainScoreboard().getTeams().add()
|
||||||
Player p = Bukkit.getPlayer(uuid);
|
Player p = Bukkit.getPlayer(getUniqueId());
|
||||||
if (p != null)
|
if (p != null)
|
||||||
p.setPlayerListName(String.format("%s%s", p.getDisplayName(), GetFormattedFlair()));
|
p.setPlayerListName(String.format("%s%s", p.getDisplayName(), GetFormattedFlair()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ public final class ChatUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getMessageString(Channel channel, CommandSender sender, String message) {
|
public static String getMessageString(Channel channel, CommandSender sender, String message) {
|
||||||
return "§c!§r[" + channel.DisplayName.get() + "] <"
|
return "§c!§r[" + channel.displayName.get() + "] <"
|
||||||
+ ChromaUtils.getDisplayName(sender) + "> " + message;
|
+ ChromaUtils.getDisplayName(sender) + "> " + message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class PluginMain extends ButtonPlugin { // Translated to Java: 2015.07.15
|
||||||
if (Bukkit.getPluginManager().isPluginEnabled("Towny"))
|
if (Bukkit.getPluginManager().isPluginEnabled("Towny"))
|
||||||
Component.registerComponent(this, new TownyComponent());
|
Component.registerComponent(this, new TownyComponent());
|
||||||
|
|
||||||
TBMCChatAPI.RegisterChatChannel(new Channel("§7RP§f", Color.Gray, "rp", null)); //Since it's null, it's recognised as global
|
TBMCChatAPI.registerChatChannel(new Channel("§7RP§f", Color.Gray, "rp", null)); //Since it's null, it's recognised as global
|
||||||
|
|
||||||
if (!setupPermissions())
|
if (!setupPermissions())
|
||||||
TBMCCoreAPI.SendException("We're in trouble", new Exception("Failed to set up permissions!"), this);
|
TBMCCoreAPI.SendException("We're in trouble", new Exception("Failed to set up permissions!"), this);
|
||||||
|
|
|
@ -21,7 +21,7 @@ public class VanillaUtils {
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
} catch (NoClassDefFoundError ex) {
|
} catch (NoClassDefFoundError ex) {
|
||||||
MainPlugin.Instance.getLogger().warning("Compatibility error, can't check if the chat is hidden by the player.");
|
MainPlugin.instance.getLogger().warning("Compatibility error, can't check if the chat is hidden by the player.");
|
||||||
return e.getGroupID(p);
|
return e.getGroupID(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,8 +49,8 @@ public final class HelpCommand extends UCommandBase {
|
||||||
"§nunderline - &n§r | §oitalic - &o§r", //
|
"§nunderline - &n§r | §oitalic - &o§r", //
|
||||||
"The format codes in tellraw should be used like \"italic\":\"true\""}); //
|
"The format codes in tellraw should be used like \"italic\":\"true\""}); //
|
||||||
} else {
|
} else {
|
||||||
String[] text = getManager().getHelpText(topicOrCommand);
|
String[] text = getManager().getCommandNode(topicOrCommand).getData().getHelpText(sender); // TODO: This only works for the main command, not subcommands
|
||||||
if (text == null)
|
if (text == null) // TODO: Null check for command node
|
||||||
sender.sendMessage(
|
sender.sendMessage(
|
||||||
new String[]{"§cError: Command not found: " + topicOrCommand,
|
new String[]{"§cError: Command not found: " + topicOrCommand,
|
||||||
"Usage example: /u accept --> /u help u accept"});
|
"Usage example: /u accept --> /u help u accept"});
|
||||||
|
|
|
@ -35,13 +35,13 @@ public class HistoryCommand extends UCommandBase {
|
||||||
sender.sendMessage("§6Chat history is disabled");
|
sender.sendMessage("§6Chat history is disabled");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
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
|
Function<Channel, LinkedList<HistoryEntry>> getThem = ch -> messages.get(ch.getIdentifier() + "_" + ch.getGroupID(sender)); //If can't see, groupID is null, and that shouldn't be in the map
|
||||||
sender.sendMessage("§6---- Chat History ----");
|
sender.sendMessage("§6---- Chat History ----");
|
||||||
Stream<Channel> stream;
|
Stream<Channel> stream;
|
||||||
if (channel == null) {
|
if (channel == null) {
|
||||||
stream = Channel.getChannels();
|
stream = Channel.getChannels();
|
||||||
} else {
|
} else {
|
||||||
Optional<Channel> och = Channel.getChannels().filter(chan -> chan.ID.equalsIgnoreCase(channel)).findAny();
|
Optional<Channel> och = Channel.getChannels().filter(chan -> chan.getIdentifier().equalsIgnoreCase(channel)).findAny();
|
||||||
if (!och.isPresent()) {
|
if (!och.isPresent()) {
|
||||||
sender.sendMessage("§cChannel not found. Use the ID, for example: /u history g");
|
sender.sendMessage("§cChannel not found. Use the ID, for example: /u history g");
|
||||||
return true;
|
return true;
|
||||||
|
@ -55,7 +55,7 @@ public class HistoryCommand extends UCommandBase {
|
||||||
for (int i = Math.max(0, arr.length - 10); i < arr.length; i++) {
|
for (int i = Math.max(0, arr.length - 10); i < arr.length; i++) {
|
||||||
HistoryEntry e = arr[i];
|
HistoryEntry e = arr[i];
|
||||||
val cm = e.chatMessage;
|
val cm = e.chatMessage;
|
||||||
sender.sendMessage("[" + e.channel.DisplayName.get() + "] " + cm.getSender().getName() + ": " + cm.getMessage());
|
sender.sendMessage("[" + e.channel.displayName.get() + "] " + cm.getSender().getName() + ": " + cm.getMessage());
|
||||||
sent.set(true);
|
sent.set(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ public class HistoryCommand extends UCommandBase {
|
||||||
|
|
||||||
@CustomTabCompleteMethod(param = "channel")
|
@CustomTabCompleteMethod(param = "channel")
|
||||||
public Iterable<String> def() {
|
public Iterable<String> def() {
|
||||||
return Channel.getChannels().map(ch -> ch.ID)::iterator;
|
return Channel.getChannels().map(Channel::getIdentifier)::iterator;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
|
@ -84,7 +84,7 @@ public class HistoryCommand extends UCommandBase {
|
||||||
val groupID = channel.getGroupID(chatMessage.getPermCheck());
|
val groupID = channel.getGroupID(chatMessage.getPermCheck());
|
||||||
if (groupID == null) return; //Just to be sure
|
if (groupID == null) return; //Just to be sure
|
||||||
synchronized (messages) {
|
synchronized (messages) {
|
||||||
var ll = messages.computeIfAbsent(channel.ID + "_" + groupID, k -> new LinkedList<>()); //<-- TIL
|
var ll = messages.computeIfAbsent(channel.getIdentifier() + "_" + groupID, k -> new LinkedList<>()); //<-- TIL
|
||||||
ll.add(new HistoryEntry(System.nanoTime(), chatMessage, channel)); //Adds as last element
|
ll.add(new HistoryEntry(System.nanoTime(), chatMessage, channel)); //Adds as last element
|
||||||
while (ll.size() > 10)
|
while (ll.size() > 10)
|
||||||
ll.remove(); //Removes the first element
|
ll.remove(); //Removes the first element
|
||||||
|
|
|
@ -10,6 +10,8 @@ import buttondevteam.lib.architecture.ListConfigData;
|
||||||
import buttondevteam.lib.chat.TBMCChatAPI;
|
import buttondevteam.lib.chat.TBMCChatAPI;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays the configured messages at the set interval when someone is online.
|
* Displays the configured messages at the set interval when someone is online.
|
||||||
*/
|
*/
|
||||||
|
@ -18,7 +20,7 @@ public class AnnouncerComponent extends Component<PluginMain> implements Runnabl
|
||||||
/**
|
/**
|
||||||
* The messages to display to players.
|
* The messages to display to players.
|
||||||
*/
|
*/
|
||||||
public ListConfigData<String> announceMessages = getConfig().getListData("announceMessages");
|
public ListConfigData<String> announceMessages = getConfig().getListData("announceMessages", Collections.emptyList());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The time in milliseconds between the messages. Use /u announce settime to set minutes.
|
* The time in milliseconds between the messages. Use /u announce settime to set minutes.
|
||||||
|
@ -39,7 +41,7 @@ public class AnnouncerComponent extends Component<PluginMain> implements Runnabl
|
||||||
}
|
}
|
||||||
if (Bukkit.getOnlinePlayers().size() == 0) continue; //Don't post to Discord if nobody is on
|
if (Bukkit.getOnlinePlayers().size() == 0) continue; //Don't post to Discord if nobody is on
|
||||||
if (announceMessages.get().size() > AnnounceMessageIndex) {
|
if (announceMessages.get().size() > AnnounceMessageIndex) {
|
||||||
TBMCChatAPI.SendSystemMessage(Channel.GlobalChat, Channel.RecipientTestResult.ALL, announceMessages.get().get(AnnounceMessageIndex), target);
|
TBMCChatAPI.SendSystemMessage(Channel.globalChat, Channel.RecipientTestResult.ALL, announceMessages.get().get(AnnounceMessageIndex), target);
|
||||||
AnnounceMessageIndex++;
|
AnnounceMessageIndex++;
|
||||||
if (AnnounceMessageIndex == announceMessages.get().size())
|
if (AnnounceMessageIndex == announceMessages.get().size())
|
||||||
AnnounceMessageIndex = 0;
|
AnnounceMessageIndex = 0;
|
||||||
|
|
|
@ -21,7 +21,7 @@ public class AppendTextComponent extends Component<PluginMain> {
|
||||||
private Map<String, IHaveConfig> appendTexts;
|
private Map<String, IHaveConfig> appendTexts;
|
||||||
|
|
||||||
private ConfigData<String[]> helpText(IHaveConfig config) {
|
private ConfigData<String[]> helpText(IHaveConfig config) {
|
||||||
return config.getData("helpText", () -> new String[]{
|
return config.getData("helpText", new String[]{
|
||||||
"Tableflip", //
|
"Tableflip", //
|
||||||
"This command appends a tableflip after your message", //
|
"This command appends a tableflip after your message", //
|
||||||
"Or just makes you tableflip", //
|
"Or just makes you tableflip", //
|
||||||
|
@ -29,7 +29,7 @@ public class AppendTextComponent extends Component<PluginMain> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private ConfigData<String> appendedText(IHaveConfig config) {
|
private ConfigData<String> appendedText(IHaveConfig config) {
|
||||||
return config.getData("appendedText", () -> "tableflip");
|
return config.getData("appendedText", "tableflip");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -101,7 +101,7 @@ public class AppendTextComponent extends Component<PluginMain> {
|
||||||
|
|
||||||
@Command2.Subcommand
|
@Command2.Subcommand
|
||||||
public void def(Command2MCSender sender, @Command2.OptionalArg @Command2.TextArg String message) {
|
public void def(Command2MCSender sender, @Command2.OptionalArg @Command2.TextArg String message) {
|
||||||
TBMCChatAPI.SendChatMessage(ChatMessage.builder(sender.getSender(), ChromaGamerBase.getFromSender(sender.getSender()),
|
TBMCChatAPI.sendChatMessage(ChatMessage.builder(sender.getSender(), ChromaGamerBase.getFromSender(sender.getSender()),
|
||||||
(message == null ? "" : message + " ") + appendedText).fromCommand(true).permCheck(sender.getPermCheck()).build());
|
(message == null ? "" : message + " ") + appendedText).fromCommand(true).permCheck(sender.getPermCheck()).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -145,7 +145,7 @@ public class FlairComponent extends Component<PluginMain> {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
p.FlairState.set(FlairStates.Commented); // Flair unknown
|
p.FlairState.set(FlairStates.Commented); // Flair unknown
|
||||||
p.SetFlair(ChatPlayer.FlairTimeNone);
|
p.SetFlair(ChatPlayer.FlairTimeNone);
|
||||||
TBMCCoreAPI.SendException("Error while checking join date for player " + p.PlayerName + "!", e, this);
|
TBMCCoreAPI.SendException("Error while checking join date for player " + p.playerName + "!", e, this);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
|
@ -178,7 +178,7 @@ public class FlairComponent extends Component<PluginMain> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ConfirmUserMessage(ChatPlayer mp) {
|
public static void ConfirmUserMessage(ChatPlayer mp) {
|
||||||
Player p = Bukkit.getPlayer(mp.getUUID());
|
Player p = Bukkit.getPlayer(mp.getUniqueId());
|
||||||
if (mp.FlairState.get().equals(FlairStates.Commented) && p != null)
|
if (mp.FlairState.get().equals(FlairStates.Commented) && p != null)
|
||||||
if (mp.UserNames.get().size() > 1)
|
if (mp.UserNames.get().size() > 1)
|
||||||
p.sendMessage(
|
p.sendMessage(
|
||||||
|
|
|
@ -49,8 +49,7 @@ public class SetFlairCommand extends AdminCommandBase {
|
||||||
if (!mp.UserNames.get().contains(username))
|
if (!mp.UserNames.get().contains(username))
|
||||||
mp.UserNames.get().add(username);
|
mp.UserNames.get().add(username);
|
||||||
}
|
}
|
||||||
sender.sendMessage(
|
sender.sendMessage("§bThe flair has been set. Player: " + mp.playerName + " Flair: " + mp.GetFormattedFlair() + "§r");
|
||||||
"§bThe flair has been set. Player: " + mp.PlayerName + " Flair: " + mp.GetFormattedFlair() + "§r");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -144,14 +144,14 @@ public class ChatProcessing {
|
||||||
|
|
||||||
if (Bukkit.getOnlinePlayers().size() == 0) return false; //Don't try to send to nobody (errors on 1.14)
|
if (Bukkit.getOnlinePlayers().size() == 0) return false; //Don't try to send to nobody (errors on 1.14)
|
||||||
|
|
||||||
Color colormode = channel.Color.get();
|
Color colormode = channel.color.get();
|
||||||
if (mp != null && mp.OtherColorMode != null)
|
if (mp != null && mp.OtherColorMode != null)
|
||||||
colormode = mp.OtherColorMode;
|
colormode = mp.OtherColorMode;
|
||||||
|
|
||||||
ArrayList<MatchProviderBase> formatters;
|
ArrayList<MatchProviderBase> formatters;
|
||||||
if (component.allowFormatting.get()) {
|
if (component.allowFormatting.get()) {
|
||||||
formatters = addFormatters(e::shouldSendTo, component);
|
formatters = addFormatters(e::shouldSendTo, component);
|
||||||
if (colormode == channel.Color.get() && mp != null && mp.RainbowPresserColorMode) { // Only overwrite channel color
|
if (colormode == channel.color.get() && mp != null && mp.RainbowPresserColorMode) { // Only overwrite channel color
|
||||||
createRPC(colormode, formatters);
|
createRPC(colormode, formatters);
|
||||||
}
|
}
|
||||||
pingedconsole = false; // Will set it to true onmatch (static constructor)
|
pingedconsole = false; // Will set it to true onmatch (static constructor)
|
||||||
|
@ -256,7 +256,7 @@ public class ChatProcessing {
|
||||||
}
|
}
|
||||||
|
|
||||||
static String getChannelID(Channel channel, String origin) {
|
static String getChannelID(Channel channel, String origin) {
|
||||||
return ("[" + (ChatUtils.MCORIGIN.equals(origin) ? "" : "§8" + origin.charAt(0) + "§r|") + channel.DisplayName.get())
|
return ("[" + (ChatUtils.MCORIGIN.equals(origin) ? "" : "§8" + origin.charAt(0) + "§r|") + channel.displayName.get())
|
||||||
+ "]";
|
+ "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,12 +35,12 @@ public class FormatterComponent extends Component<PluginMain> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void enable() {
|
protected void enable() {
|
||||||
MainPlugin.Instance.setChatHandlerEnabled(false); //Disable Core chat handler - if this component is disabled then let it do its job
|
MainPlugin.instance.setChatHandlerEnabled(false); //Disable Core chat handler - if this component is disabled then let it do its job
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void disable() {
|
protected void disable() {
|
||||||
MainPlugin.Instance.setChatHandlerEnabled(true);
|
MainPlugin.instance.setChatHandlerEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class FTopCommand extends ICommand2MC {
|
||||||
val ai = new AtomicInteger();
|
val ai = new AtomicInteger();
|
||||||
sender.sendMessage("§6---- Top Fs ----");
|
sender.sendMessage("§6---- Top Fs ----");
|
||||||
sender.sendMessage(Arrays.stream(cached).skip((i - 1) * 10).limit(i * 10)
|
sender.sendMessage(Arrays.stream(cached).skip((i - 1) * 10).limit(i * 10)
|
||||||
.map(cp -> String.format("%d. %s - %f.2", ai.incrementAndGet(), cp.PlayerName.get(), cp.getF()))
|
.map(cp -> String.format("%d. %s - %f.2", ai.incrementAndGet(), cp.playerName.get(), cp.getF()))
|
||||||
.collect(Collectors.joining("\n")));
|
.collect(Collectors.joining("\n")));
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class FunComponent extends Component<PluginMain> implements Listener {
|
||||||
/**
|
/**
|
||||||
* The strings that count as laughs, see unlol.
|
* The strings that count as laughs, see unlol.
|
||||||
*/
|
*/
|
||||||
private final ConfigData<String[]> laughStrings = getConfig().getData("laughStrings", () -> new String[]{"xd", "lel", "lawl", "kek", "lmao", "hue", "hah", "rofl"});
|
private final ConfigData<String[]> laughStrings = getConfig().getData("laughStrings", new String[]{"xd", "lel", "lawl", "kek", "lmao", "hue", "hah", "rofl"});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The "Press F to pay respects" meme in Minecraft. It will randomly appear on player death and keep track of how many "F"s are said in chat.
|
* The "Press F to pay respects" meme in Minecraft. It will randomly appear on player death and keep track of how many "F"s are said in chat.
|
||||||
|
@ -113,7 +113,7 @@ public class FunComponent extends Component<PluginMain> implements Listener {
|
||||||
ActiveF = false;
|
ActiveF = false;
|
||||||
if (FPlayer != null && FPlayer.FCount.get() < Integer.MAX_VALUE - 1)
|
if (FPlayer != null && FPlayer.FCount.get() < Integer.MAX_VALUE - 1)
|
||||||
FPlayer.FCount.set(FPlayer.FCount.get() + Fs.size());
|
FPlayer.FCount.set(FPlayer.FCount.get() + Fs.size());
|
||||||
TBMCChatAPI.SendSystemMessage(Channel.GlobalChat, Channel.RecipientTestResult.ALL,
|
TBMCChatAPI.SendSystemMessage(Channel.globalChat, Channel.RecipientTestResult.ALL,
|
||||||
"§b" + Fs.size() + " " + (Fs.size() == 1 ? "person" : "people")
|
"§b" + Fs.size() + " " + (Fs.size() == 1 ? "person" : "people")
|
||||||
+ " paid their respects.§r", fTarget);
|
+ " paid their respects.§r", fTarget);
|
||||||
Fs.clear();
|
Fs.clear();
|
||||||
|
@ -127,7 +127,7 @@ public class FunComponent extends Component<PluginMain> implements Listener {
|
||||||
Fs.clear();
|
Fs.clear();
|
||||||
FPlayer = TBMCPlayer.getPlayer(e.getEntity().getUniqueId(), ChatPlayer.class);
|
FPlayer = TBMCPlayer.getPlayer(e.getEntity().getUniqueId(), ChatPlayer.class);
|
||||||
FPlayer.FDeaths.set(FPlayer.FDeaths.get() + 1);
|
FPlayer.FDeaths.set(FPlayer.FDeaths.get() + 1);
|
||||||
TBMCChatAPI.SendSystemMessage(Channel.GlobalChat, Channel.RecipientTestResult.ALL,
|
TBMCChatAPI.SendSystemMessage(Channel.globalChat, Channel.RecipientTestResult.ALL,
|
||||||
"§bPress F to pay respects.§r", fTarget);
|
"§bPress F to pay respects.§r", fTarget);
|
||||||
Ftask = Bukkit.getScheduler().runTaskLaterAsynchronously(PluginMain.Instance, tt, 15 * 20);
|
Ftask = Bukkit.getScheduler().runTaskLaterAsynchronously(PluginMain.Instance, tt, 15 * 20);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package buttondevteam.chat.components.fun;
|
package buttondevteam.chat.components.fun;
|
||||||
|
|
||||||
import buttondevteam.core.component.channel.Channel;
|
import buttondevteam.core.component.channel.Channel;
|
||||||
|
import buttondevteam.core.component.restart.RestartComponent;
|
||||||
import buttondevteam.core.component.restart.ScheduledRestartCommand;
|
import buttondevteam.core.component.restart.ScheduledRestartCommand;
|
||||||
import buttondevteam.lib.ChromaUtils;
|
import buttondevteam.lib.ChromaUtils;
|
||||||
import buttondevteam.lib.ScheduledServerRestartEvent;
|
import buttondevteam.lib.ScheduledServerRestartEvent;
|
||||||
|
@ -36,7 +37,7 @@ public class PressCommand extends ICommand2MC implements Listener {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pressers.add(sender);
|
pressers.add(sender);
|
||||||
TBMCChatAPI.SendSystemMessage(Channel.GlobalChat, Channel.RecipientTestResult.ALL, String.format("§b-- %s §bpressed at %.0fs", ChromaUtils.getDisplayName(sender), command.getRestartCounter() / 20f), command.getComponent().getRestartBroadcast());
|
TBMCChatAPI.SendSystemMessage(Channel.globalChat, Channel.RecipientTestResult.ALL, String.format("§b-- %s §bpressed at %.0fs", ChromaUtils.getDisplayName(sender), command.getRestartCounter() / 20f), ((RestartComponent) command.getComponent()).getRestartBroadcast());
|
||||||
command.setRestartCounter(startTicks);
|
command.setRestartCounter(startTicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,6 +47,6 @@ public class PressCommand extends ICommand2MC implements Listener {
|
||||||
pressers = new HashSet<>();
|
pressers = new HashSet<>();
|
||||||
startTicks = event.getRestartTicks();
|
startTicks = event.getRestartTicks();
|
||||||
if (Bukkit.getOnlinePlayers().size() > 0)
|
if (Bukkit.getOnlinePlayers().size() > 0)
|
||||||
TBMCChatAPI.SendSystemMessage(Channel.GlobalChat, Channel.RecipientTestResult.ALL, "§b-- Do /press to reset the timer. You may only press once.", command.getComponent().getRestartBroadcast());
|
TBMCChatAPI.SendSystemMessage(Channel.globalChat, Channel.RecipientTestResult.ALL, "§b-- Do /press to reset the timer. You may only press once.", ((RestartComponent) command.getComponent()).getRestartBroadcast());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ public final class UnlolCommand extends ICommand2MC {
|
||||||
String msg = ChromaUtils.getDisplayName(sender)
|
String msg = ChromaUtils.getDisplayName(sender)
|
||||||
+ (lol.Lolornot ? " unlolled " : " unlaughed ")
|
+ (lol.Lolornot ? " unlolled " : " unlaughed ")
|
||||||
+ ChromaUtils.getDisplayName(lol.Lolowner);
|
+ ChromaUtils.getDisplayName(lol.Lolowner);
|
||||||
TBMCChatAPI.SendSystemMessage(Channel.GlobalChat, Channel.RecipientTestResult.ALL, msg, target);
|
TBMCChatAPI.SendSystemMessage(Channel.globalChat, Channel.RecipientTestResult.ALL, msg, target);
|
||||||
Lastlol.remove(lol.Chatevent.getChannel());
|
Lastlol.remove(lol.Chatevent.getChannel());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class TownyAnnouncer {
|
||||||
message, target, ChatUtils.MCORIGIN);
|
message, target, ChatUtils.MCORIGIN);
|
||||||
break;
|
break;
|
||||||
case "Global":
|
case "Global":
|
||||||
TBMCChatAPI.SendSystemMessage(Channel.GlobalChat,
|
TBMCChatAPI.SendSystemMessage(Channel.globalChat,
|
||||||
Channel.RecipientTestResult.ALL,
|
Channel.RecipientTestResult.ALL,
|
||||||
message, target, ChatUtils.MCORIGIN);
|
message, target, ChatUtils.MCORIGIN);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -53,9 +53,9 @@ public class TownyComponent extends Component<PluginMain> {
|
||||||
}
|
}
|
||||||
Towns = dataSource.getTowns().stream().map(Town::getName).collect(Collectors.toCollection(ArrayList::new)); // Creates a snapshot of towns, new towns will be added when needed
|
Towns = dataSource.getTowns().stream().map(Town::getName).collect(Collectors.toCollection(ArrayList::new)); // Creates a snapshot of towns, new towns will be added when needed
|
||||||
Nations = dataSource.getNations().stream().map(Nation::getName).collect(Collectors.toCollection(ArrayList::new)); // Same here but with nations
|
Nations = dataSource.getNations().stream().map(Nation::getName).collect(Collectors.toCollection(ArrayList::new)); // Same here but with nations
|
||||||
TBMCChatAPI.RegisterChatChannel(
|
TBMCChatAPI.registerChatChannel(
|
||||||
TownChat = new Channel("§3TC§f", Color.DarkAqua, "tc", s -> checkTownNationChat(s, false)));
|
TownChat = new Channel("§3TC§f", Color.DarkAqua, "tc", s -> checkTownNationChat(s, false)));
|
||||||
TBMCChatAPI.RegisterChatChannel(
|
TBMCChatAPI.registerChatChannel(
|
||||||
NationChat = new Channel("§6NC§f", Color.Gold, "nc", s -> checkTownNationChat(s, true)));
|
NationChat = new Channel("§6NC§f", Color.Gold, "nc", s -> checkTownNationChat(s, true)));
|
||||||
TownyAnnouncer.setup(TownChat, NationChat);
|
TownyAnnouncer.setup(TownChat, NationChat);
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ public class TownyComponent extends Component<PluginMain> {
|
||||||
|
|
||||||
public Consumer<Player> handleSpiesInit(Channel channel, TellrawPart json, Function<TellrawPart, String> toJson,
|
public Consumer<Player> handleSpiesInit(Channel channel, TellrawPart json, Function<TellrawPart, String> toJson,
|
||||||
CommandSender sender, String message) {
|
CommandSender sender, String message) {
|
||||||
if (channel.ID.equals(TownChat.ID) || channel.ID.equals(NationChat.ID)) {
|
if (channel.getIdentifier().equals(TownChat.getIdentifier()) || channel.getIdentifier().equals(NationChat.getIdentifier())) {
|
||||||
((List<TellrawPart>) json.getExtra()).add(0, new TellrawPart("[SPY]"));
|
((List<TellrawPart>) json.getExtra()).add(0, new TellrawPart("[SPY]"));
|
||||||
String jsonstr = toJson.apply(json);
|
String jsonstr = toJson.apply(json);
|
||||||
return p -> handleSpies(channel, p, jsonstr, sender, message);
|
return p -> handleSpies(channel, p, jsonstr, sender, message);
|
||||||
|
@ -76,7 +76,7 @@ public class TownyComponent extends Component<PluginMain> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleSpies(Channel channel, Player p, String jsonstr, CommandSender sender, String message) {
|
private void handleSpies(Channel channel, Player p, String jsonstr, CommandSender sender, String message) {
|
||||||
if (channel.ID.equals(TownChat.ID) || channel.ID.equals(NationChat.ID)) {
|
if (channel.getIdentifier().equals(TownChat.getIdentifier()) || channel.getIdentifier().equals(NationChat.getIdentifier())) {
|
||||||
try {
|
try {
|
||||||
if (dataSource.getResident(p.getName()).hasMode("spy"))
|
if (dataSource.getResident(p.getName()).hasMode("spy"))
|
||||||
if (!VanillaUtils.tellRaw(p, jsonstr))
|
if (!VanillaUtils.tellRaw(p, jsonstr))
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class PlayerListener implements Listener {
|
||||||
ChatPlayer cp = e.getPlayer().getAs(ChatPlayer.class);
|
ChatPlayer cp = e.getPlayer().getAs(ChatPlayer.class);
|
||||||
if (cp == null)
|
if (cp == null)
|
||||||
return;
|
return;
|
||||||
e.addInfo("Minecraft name: " + cp.PlayerName.get());
|
e.addInfo("Minecraft name: " + cp.playerName.get());
|
||||||
if (cp.UserName.get() != null && cp.UserName.get().length() > 0)
|
if (cp.UserName.get() != null && cp.UserName.get().length() > 0)
|
||||||
e.addInfo("Reddit name: " + cp.UserName.get());
|
e.addInfo("Reddit name: " + cp.UserName.get());
|
||||||
if (ComponentManager.isEnabled(FlairComponent.class)) {
|
if (ComponentManager.isEnabled(FlairComponent.class)) {
|
||||||
|
@ -74,7 +74,7 @@ public class PlayerListener implements Listener {
|
||||||
try {
|
try {
|
||||||
if (e.isCancelled())
|
if (e.isCancelled())
|
||||||
return;
|
return;
|
||||||
HistoryCommand.addChatMessage(e.getCm(), e.getChannel());
|
HistoryCommand.addChatMessage(e.getChatMessage(), e.getChannel());
|
||||||
e.setCancelled(FormatterComponent.handleChat(e));
|
e.setCancelled(FormatterComponent.handleChat(e));
|
||||||
} catch (NoClassDefFoundError | Exception ex) { // Weird things can happen
|
} catch (NoClassDefFoundError | Exception ex) { // Weird things can happen
|
||||||
if (lastError < System.nanoTime() - 1000L * 1000L * 1000L * 60 * 60 //60 mins
|
if (lastError < System.nanoTime() - 1000L * 1000L * 1000L * 60 * 60 //60 mins
|
||||||
|
@ -82,7 +82,7 @@ public class PlayerListener implements Listener {
|
||||||
lastError = System.nanoTime(); //I put the whole thing in the if to protect against race conditions
|
lastError = System.nanoTime(); //I put the whole thing in the if to protect against race conditions
|
||||||
for (Player p : Bukkit.getOnlinePlayers())
|
for (Player p : Bukkit.getOnlinePlayers())
|
||||||
if (e.shouldSendTo(p))
|
if (e.shouldSendTo(p))
|
||||||
p.sendMessage("[" + e.getChannel().DisplayName.get() + "] §cSome features in the message below might be unavailable due to an error.");
|
p.sendMessage("[" + e.getChannel().displayName.get() + "] §cSome features in the message below might be unavailable due to an error.");
|
||||||
}
|
}
|
||||||
ChatUtils.sendChatMessage(e);
|
ChatUtils.sendChatMessage(e);
|
||||||
TBMCCoreAPI.SendException("An error occured while processing a chat message!", ex, PluginMain.Instance);
|
TBMCCoreAPI.SendException("An error occured while processing a chat message!", ex, PluginMain.Instance);
|
||||||
|
|
|
@ -134,7 +134,7 @@ public class ChatFormatIT {
|
||||||
public void testMessage() {
|
public void testMessage() {
|
||||||
System.out.println("Testing: " + message);
|
System.out.println("Testing: " + message);
|
||||||
ArrayList<MatchProviderBase> cfs = ChatProcessing.addFormatters(p -> true, null);
|
ArrayList<MatchProviderBase> cfs = ChatProcessing.addFormatters(p -> true, null);
|
||||||
final String chid = ChatProcessing.getChannelID(Channel.GlobalChat, ChatUtils.MCORIGIN);
|
final String chid = ChatProcessing.getChannelID(Channel.globalChat, ChatUtils.MCORIGIN);
|
||||||
if (rainbowMode)
|
if (rainbowMode)
|
||||||
ChatProcessing.createRPC(Color.White, cfs);
|
ChatProcessing.createRPC(Color.White, cfs);
|
||||||
final TellrawPart tp = ChatProcessing.createTellraw(sender, message, null, null, null, chid, ChatUtils.MCORIGIN);
|
final TellrawPart tp = ChatProcessing.createTellraw(sender, message, null, null, null, chid, ChatUtils.MCORIGIN);
|
||||||
|
|
Loading…
Reference in a new issue