Skip to content

Commit

Permalink
Version 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
MrMicky-FR committed Feb 27, 2021
1 parent ee4b60e commit 4fa4574
Show file tree
Hide file tree
Showing 19 changed files with 415 additions and 122 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Java CI

on:
push:
pull_request:

jobs:
build:
name: Build

runs-on: ubuntu-latest

strategy:
matrix:
java-version: [1.8, 11]

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Setup JDK ${{ matrix.java-version }}
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java-version }}

- name: Build
run: mvn -B package
13 changes: 0 additions & 13 deletions .travis.yml

This file was deleted.

26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# ViaChatFixer
[![Build Status](https://travis-ci.org/MrMicky-FR/ViaChatFixer.svg?branch=master)](https://travis-ci.org/MrMicky-FR/ViaChatFixer)
# ViaChatFixer

ViaChatFixer is a Spigot plugin that allow 1.11+ players to have longer chat messages on 1.8-1.10 servers with ViaVersion
[![Java CI](https://github.com/MrMicky-FR/ViaChatFixer/actions/workflows/build.yml/badge.svg)](https://github.com/MrMicky-FR/ViaChatFixer/actions/workflows/build.yml)

In Minecraft 1.11, the maximum messages length has gone from 100 characters to 256 characters.
So if your server is under 1.11, 1.11 and higher players will have their chat messages cut at 100 characters.
ViaChatFixer is a Spigot plugin that allow 1.11+ players to have longer chat messages on 1.8-1.10 servers with ViaVersion

This plugin fix this problem, so 1.11 and higher players will able to send longer chat messages up to 256 characters :)
In Minecraft 1.11, the maximum messages length has gone from 100 characters to 256 characters. So if your server is under 1.11, 1.11 and higher
players will have their chat messages cut at 100 characters.

**The plugin is currently in beta, so if you find bugs please open an issue**
This plugin fix this problem, so 1.11 and higher players will be able to send longer chat messages up to 256 characters.

## Downloads

Expand All @@ -17,12 +16,13 @@ You can download releases and find more information on [SpigotMC](https://www.sp
## Installation

Just put the ViaChatFixer jar in your plugins folder.
Currently this plugin only works on Spigot, but Sponge support should be added soon.
This plugin can work with BungeeCord as long as ViaVersion and this plugin are on the Spigot servers.

**All players online during a reload will not be able to have longer chat messages until they reconnect**
ViaChatFixer currently supports ViaVersion v3.0 or higher.

All players online during a reload will not be able to have longer chat messages until they reconnect.

## Supported Platforms

## Planned features
ViaChatFixer can be installed on Bukkit/Spigot/Paper servers or on Sponge servers.

* Sponge support
* BungeeCord support _(not sure)_
If you are using a proxy, ViaVersion and ViaChatFixer must be installed on the backend servers.
14 changes: 7 additions & 7 deletions bukkit/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>fr.mrmicky</groupId>
<artifactId>viachatfixer</artifactId>
<version>0.3.0</version>
<version>1.0.0</version>
</parent>

<artifactId>viachatfixer-bukkit</artifactId>
Expand All @@ -22,16 +22,16 @@
</repositories>

<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.8.8-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>fr.mrmicky</groupId>
<artifactId>viachatfixer-common</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.10.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,48 +1,56 @@
package fr.mrmicky.viachatfixer.bukkit;

import fr.mrmicky.viachatfixer.ViaChatFixerPlatform;
import fr.mrmicky.viachatfixer.handlers.ChatHandler;
import fr.mrmicky.viachatfixer.handlers.via.ViaChatHandler;
import fr.mrmicky.viachatfixer.common.ChatHandler;
import fr.mrmicky.viachatfixer.common.ViaChatFixerPlatform;
import fr.mrmicky.viachatfixer.common.logger.JavaLoggerAdapter;
import fr.mrmicky.viachatfixer.common.logger.LoggerAdapter;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.logging.Level;
public final class ViaChatFixerBukkit extends JavaPlugin implements Listener, ViaChatFixerPlatform {

public final class ViaChatFixerBukkit extends JavaPlugin implements ViaChatFixerPlatform, Listener {
private final ChatHandler chatHandler = new ChatHandler(this);

private ChatHandler chatHandler;
private LoggerAdapter logger;

@Override
public void onLoad() {
this.logger = new JavaLoggerAdapter(getLogger());
}

@Override
public void onEnable() {
if (getServer().getPluginManager().getPlugin("ViaVersion") == null) {
getLogger().severe("ViaVersion is not installed");
this.logger.error("You need to install ViaVersion to use ViaChatFixer");
getServer().getPluginManager().disablePlugin(this);
return;
}

chatHandler = new ViaChatHandler(this);

// Only load when ViaVersion is loaded
getServer().getScheduler().runTask(this, () -> {
try {
chatHandler.init();
this.chatHandler.init();

getServer().getPluginManager().registerEvents(this, this);
} catch (Exception e) {
getLogger().log(Level.SEVERE, "An error occurred while enabling", e);
this.logger.error("An error occurred during initialization", e);
getServer().getPluginManager().disablePlugin(this);
return;
}

getServer().getPluginManager().registerEvents(this, this);
});
}

@Override
public LoggerAdapter getLoggerAdapter() {
return this.logger;
}

@EventHandler(priority = EventPriority.LOWEST)
public void onAsyncPlayerChat(AsyncPlayerChatEvent e) {
String message = chatHandler.handle(e.getPlayer().getUniqueId());
String message = this.chatHandler.handle(e.getPlayer().getUniqueId());

if (message != null) {
e.setMessage(message);
Expand All @@ -51,7 +59,7 @@ public void onAsyncPlayerChat(AsyncPlayerChatEvent e) {

@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerCommand(PlayerCommandPreprocessEvent e) {
String message = chatHandler.handle(e.getPlayer().getUniqueId());
String message = this.chatHandler.handle(e.getPlayer().getUniqueId());

if (message != null) {
e.setMessage(message);
Expand Down
18 changes: 17 additions & 1 deletion common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,27 @@
<parent>
<groupId>fr.mrmicky</groupId>
<artifactId>viachatfixer</artifactId>
<version>0.3.0</version>
<version>1.0.0</version>
</parent>

<artifactId>viachatfixer-common</artifactId>

<name>ViaChatFixerCommon</name>

<repositories>
<repository>
<id>viaversion-repo</id>
<url>https://repo.viaversion.com/</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>us.myles</groupId>
<artifactId>viaversion</artifactId>
<version>3.0.0</version>
<scope>provided</scope>
</dependency>
</dependencies>

</project>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package fr.mrmicky.viachatfixer.handlers.via;
package fr.mrmicky.viachatfixer.common;

import fr.mrmicky.viachatfixer.ViaChatFixerPlatform;
import fr.mrmicky.viachatfixer.handlers.ChatHandler;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.protocol.Protocol;
Expand All @@ -17,20 +15,21 @@
import java.util.Set;
import java.util.UUID;

public class ViaChatHandler implements ChatHandler {
public class ChatHandler {

private final Set<UUID> unknownPlayers = new HashSet<>();

private final ViaChatFixerPlatform platform;

public ViaChatHandler(ViaChatFixerPlatform platform) {
private boolean enabled = false;

public ChatHandler(ViaChatFixerPlatform platform) {
this.platform = platform;
}

@Override
public void init() {
if (ProtocolRegistry.SERVER_PROTOCOL >= ProtocolVersion.v1_11.getId()) {
platform.getLogger().warning("This plugin is not required on 1.11+ servers, you can just remove it :)");
this.platform.getLoggerAdapter().warn("This plugin is not required on 1.11+ servers, you can just remove it.");
return;
}

Expand Down Expand Up @@ -72,34 +71,46 @@ public void registerMap() {
});
}
}, true);

this.enabled = true;
}

@Override
public String handle(UUID uuid) {
if (!this.enabled) {
return null;
}

ChatTracker chatTracker = getChatTracker(uuid);

if (chatTracker == null) {
return null;
}

String message = chatTracker.getLastMessage();

chatTracker.reset();

return message;
}

private ChatTracker getChatTracker(UUID uuid) {
UserConnection connection = Via.getManager().getConnection(uuid);

if (connection == null) {
if (unknownPlayers.add(uuid)) {
platform.getLogger().warning("Unknown connection for player with UUID " + uuid);
if (this.unknownPlayers.add(uuid)) {
this.platform.getLoggerAdapter().warn("Unknown connection for player with UUID " + uuid);
}

return null;
}

ChatTracker chatTracker = connection.get(ChatTracker.class);

if (chatTracker == null || chatTracker.getLastMessage() == null) {
return null;
}

if (!chatTracker.isValid(100)) {
if (chatTracker != null && !chatTracker.isValid(100)) {
chatTracker.reset();
return null;
}

String message = chatTracker.getLastMessage();

chatTracker.reset();

return message;
return chatTracker;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.mrmicky.viachatfixer.handlers.via;
package fr.mrmicky.viachatfixer.common;

import us.myles.ViaVersion.api.data.StoredObject;
import us.myles.ViaVersion.api.data.UserConnection;
Expand All @@ -13,20 +13,24 @@ public ChatTracker(UserConnection user) {
}

public String getLastMessage() {
return lastMessage;
return this.lastMessage;
}

public boolean isValid(int time) {
return (System.currentTimeMillis() - lastMessageTime) < time;
if (this.lastMessage == null) {
return false;
}

return (System.currentTimeMillis() - this.lastMessageTime) < time;
}

public void updateLastMessage(String message) {
lastMessage = message;
lastMessageTime = System.currentTimeMillis();
this.lastMessage = message;
this.lastMessageTime = System.currentTimeMillis();
}

public void reset() {
lastMessage = null;
lastMessageTime = 0;
this.lastMessage = null;
this.lastMessageTime = 0;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package fr.mrmicky.viachatfixer.common;

import fr.mrmicky.viachatfixer.common.logger.LoggerAdapter;

public interface ViaChatFixerPlatform {

LoggerAdapter getLoggerAdapter();

}
Loading

0 comments on commit 4fa4574

Please sign in to comment.