Greentext formatter, doc and stuff
This commit is contained in:
parent
59dbc78b52
commit
a63f2bb256
4 changed files with 19 additions and 13 deletions
2
pom.xml
2
pom.xml
|
@ -204,7 +204,7 @@
|
|||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.12.2-R0.1-SNAPSHOT</version>
|
||||
<version>1.16.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- <dependency>
|
||||
|
|
|
@ -45,9 +45,10 @@ public class ChatProcessing {
|
|||
private static final Color[] RainbowPresserColors = new Color[]{Color.Red, Color.Gold, Color.Yellow, Color.Green,
|
||||
Color.Blue, Color.DarkPurple};
|
||||
private static final Pattern WORD_PATTERN = Pattern.compile("\\S+");
|
||||
private static final Pattern GREENTEXT_PATTERN = Pattern.compile("^>(?:.|\\s)*");
|
||||
private static boolean pingedconsole = false;
|
||||
|
||||
private static ArrayList<MatchProviderBase> commonFormatters = Lists.newArrayList(
|
||||
private static final ArrayList<MatchProviderBase> commonFormatters = Lists.newArrayList(
|
||||
new RangeMatchProvider("bold", "**", FormatSettings.builder().bold(true).build()),
|
||||
new RangeMatchProvider("italic", "*", FormatSettings.builder().italic(true).build()),
|
||||
new RangeMatchProvider("underlined", "__", FormatSettings.builder().underlined(true).build()),
|
||||
|
@ -88,8 +89,9 @@ public class ChatProcessing {
|
|||
var player = players.get(playerC);
|
||||
playPingSound(player, ComponentManager.getIfEnabled(FormatterComponent.class));
|
||||
return "@someone (" + player.getDisplayName() + "§r)";
|
||||
}).build(), true, "@someone"));
|
||||
private static Gson gson = new GsonBuilder()
|
||||
}).build(), true, "@someone"),
|
||||
new RegexMatchProvider("greentext", GREENTEXT_PATTERN, FormatSettings.builder().color(Color.Green).build()));
|
||||
private static final Gson gson = new GsonBuilder()
|
||||
.registerTypeHierarchyAdapter(TellrawSerializableEnum.class, new TellrawSerializer.TwEnum())
|
||||
.registerTypeHierarchyAdapter(Collection.class, new TellrawSerializer.TwCollection())
|
||||
.registerTypeAdapter(Boolean.class, new TellrawSerializer.TwBool())
|
||||
|
@ -120,12 +122,18 @@ public class ChatProcessing {
|
|||
mp = e.getUser().getAs(ChatPlayer.class); //May be null
|
||||
|
||||
if (mp != null) {
|
||||
if (System.nanoTime() - mp.LastMessageTime < 1000 * component.minTimeBetweenMessages().get()) { //0.1s by default
|
||||
sender.sendMessage("§cYou are sending messages too fast!");
|
||||
if (System.nanoTime() - mp.LastMessageTime < 1000 * 1000 * component.minTimeBetweenMessages().get()) { //0.1s by default
|
||||
sender.sendMessage("§cYou are sending messages too quickly!");
|
||||
return true;
|
||||
}
|
||||
mp.LastMessageTime = System.nanoTime();
|
||||
}
|
||||
//DimensionManager.a()
|
||||
//IRegistry.ae
|
||||
//Bukkit.createWorld()
|
||||
//MinecraftServer.reload()
|
||||
//IRegistry
|
||||
//CraftServer
|
||||
|
||||
doFunStuff(sender, e, message);
|
||||
|
||||
|
@ -139,9 +147,6 @@ public class ChatProcessing {
|
|||
Color colormode = channel.Color().get();
|
||||
if (mp != null && mp.OtherColorMode != null)
|
||||
colormode = mp.OtherColorMode;
|
||||
if (message.startsWith(">"))
|
||||
colormode = Color.Green;
|
||||
// If greentext, ignore channel or player colors
|
||||
|
||||
ArrayList<MatchProviderBase> formatters;
|
||||
if (component.allowFormatting().get()) {
|
||||
|
@ -174,7 +179,8 @@ public class ChatProcessing {
|
|||
}
|
||||
val tc = ComponentManager.getIfEnabled(TownyComponent.class);
|
||||
Consumer<Player> spyConsumer = null;
|
||||
if (tc != null) spyConsumer = tc.handleSpiesInit(channel, json, ChatProcessing::toJson, sender, message);
|
||||
if (tc != null)
|
||||
spyConsumer = tc.handleSpiesInit(channel, json, ChatProcessing::toJson, sender, message);
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
final String group;
|
||||
if (player != null
|
||||
|
|
|
@ -10,7 +10,7 @@ import buttondevteam.lib.architecture.ConfigData;
|
|||
/**
|
||||
* This component handles the custom processing of chat messages. If this component is disabled channels won't be supported in Minecraft.
|
||||
* If you only want to disable the formatting features, set allowFormatting to false.
|
||||
* If you're using another chat plugin, you should disable the whole component.
|
||||
* If you're using another chat plugin, you should disable the whole component but that will make it impossible to use channels.
|
||||
*/
|
||||
public class FormatterComponent extends Component<PluginMain> {
|
||||
/**
|
||||
|
@ -41,10 +41,9 @@ public class FormatterComponent extends Component<PluginMain> {
|
|||
return getConfig().getData("minTimeBetweenMessages", 100);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void enable() {
|
||||
MainPlugin.Instance.setChatHandlerEnabled(false); //Disable Core chat handler - if this component is disabled then let it do it's job
|
||||
MainPlugin.Instance.setChatHandlerEnabled(false); //Disable Core chat handler - if this component is disabled then let it do its job
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -87,6 +87,7 @@ public class ChatFormatIT {
|
|||
space, new TellrawPart("O").setColor(Color.DarkPurple)).setRainbowMode());
|
||||
list.add(new ChatFormatIT(sender, "***test*** test", new TellrawPart("test").setColor(Color.White)
|
||||
.setItalic(true).setBold(true), new TellrawPart(" test").setColor(Color.White)));
|
||||
list.add(new ChatFormatIT(sender, ">test message\nheh", new TellrawPart(">test message\nheh").setColor(Color.Green)));
|
||||
|
||||
return list;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue