Skip to content

Commit

Permalink
Merge branch 'main' into feat/fabric
Browse files Browse the repository at this point in the history
# Conflicts:
#	gradle.properties
#	settings.gradle.kts
  • Loading branch information
4drian3d committed Oct 28, 2023
2 parents 04de198 + c49493e commit 32d38e3
Show file tree
Hide file tree
Showing 27 changed files with 104 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

steps:
- name: Checkout Repository
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4

- name: Set up JDK 17
uses: actions/setup-java@v3
Expand Down
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,20 @@
Allows you to cancel or modify messages or commands from Velocity without synchronization problems

## Requirements
- Java 17+
- Velocity 3.2.0+
#### **Backend:**
- Java 17+
- Paper 1.19.4+ or Sponge 1.16.5+ (API 8.1+)
- Sponge API 8.1/10+
- Minestom

## Features
- Transmit the modification and cancellation status of Velocity messages and commands to your backend server using plugin messages. This avoids chat chain synchronization problems and avoids Velocity's security check by correctly synchronizing messages.
- Chat reporting support using Velocity (can be disabled using external plugins like FreedomChat, **not recommended**)
- Ability to remove the unsecured chat warning when logging into each server. Requires [VPacketEvents](https://modrinth.com/plugin/vpacketevents) or [PacketEvents](https://modrinth.com/plugin/packetevents)

![SignedVelocitySignedStatus](https://github.com/4drian3d/SignedVelocity/assets/68704415/4a7e2bec-c167-4de1-b827-d188d0afaa56)

## Installation
In order for SignedVelocity to work, you must install it on both Velocity and all your servers
Expand All @@ -26,6 +37,10 @@ In order for SignedVelocity to work, you must install it on both Velocity and al
SignedVelocity-Sponge-8 supports API 8.1 and 9, SignedVelocity-Sponge-10 supports API 10 and 11
- Drag and drop on your Sponge plugins folder
- Start your server
### Minestom
- Download SignedVelocity-Minestom
- Drag and drop on your Minestom extensions folder
- Start your server

[![](https://www.bisecthosting.com/partners/custom-banners/6fa909d5-ad2b-42c2-a7ec-1c51f8b6384f.webp)](https://www.bisecthosting.com/4drian3d)

Expand All @@ -42,4 +57,4 @@ SignedVelocity solves all these problems, synchronizing the blocking and modific
[![Watch the video](https://img.youtube.com/vi/5bfYy1kQwGk/maxresdefault.jpg)](https://www.youtube.com/watch?v=5bfYy1kQwGk)

## Metrics
[![metrics](https://bstats.org/signatures/velocity/SignedVelocity.svg)](https://bstats.org/plugin/velocity/SignedVelocity/18937)
[![metrics](https://bstats.org/signatures/velocity/SignedVelocity.svg)](https://bstats.org/plugin/velocity/SignedVelocity/18937)
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package io.github._4drian3d.signedvelocity.common;

public final class PropertyHolder {
private PropertyHolder() {
throw new AssertionError();
}

public static boolean readBoolean(final String property, final boolean defaultValue) {
final String value = System.getProperty(property);
if (value == null) {
return defaultValue;
} else {
try {
return "true".equalsIgnoreCase(value);
} catch (final Exception ignored) {
return defaultValue;
}

}
}

public static String readValue(final String property, final String defaultValue) {
return System.getProperty(property, defaultValue);
}

public static int readInt(final String property, final int defaultValue) {
final String value = System.getProperty(property);
if (value == null) {
return defaultValue;
} else {
try {
return Integer.parseInt(value);
} catch (final Exception ignored) {
return defaultValue;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package io.github._4drian3d.signedvelocity.common;
package io.github._4drian3d.signedvelocity.common.queue;

import io.github._4drian3d.signedvelocity.common.PropertyHolder;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;

public final class QueuedData {
private static final int timeout = Integer.getInteger("io.github._4drian3d.signedvelocity.timeout", 135);
private static final int timeout = PropertyHolder.readInt("io.github._4drian3d.signedvelocity.timeout", 140);
private volatile CompletableFuture<SignedResult> futureResult;

// first
Expand Down Expand Up @@ -35,6 +37,7 @@ public CompletableFuture<SignedResult> nextResult() {
}
}

@SuppressWarnings("ReplaceNullCheck")
public CompletableFuture<SignedResult> nextResultWithoutAdvance() {
if (this.futureResult == null) {
// UnSynchronized
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github._4drian3d.signedvelocity.common;
package io.github._4drian3d.signedvelocity.common.queue;

import org.jetbrains.annotations.NotNull;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github._4drian3d.signedvelocity.common;
package io.github._4drian3d.signedvelocity.common.queue;

import org.jetbrains.annotations.Nullable;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github._4drian3d.signedvelocity.minestom;

import io.github._4drian3d.signedvelocity.common.SignedQueue;
import io.github._4drian3d.signedvelocity.common.queue.SignedQueue;
import io.github._4drian3d.signedvelocity.minestom.listener.PlayerChatListener;
import io.github._4drian3d.signedvelocity.minestom.listener.PlayerCommandListener;
import io.github._4drian3d.signedvelocity.minestom.listener.PluginMessageListener;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github._4drian3d.signedvelocity.minestom.listener;

import io.github._4drian3d.signedvelocity.common.SignedQueue;
import io.github._4drian3d.signedvelocity.common.queue.SignedQueue;
import io.github._4drian3d.signedvelocity.minestom.SignedVelocity;
import net.minestom.server.entity.Player;
import net.minestom.server.event.player.PlayerChatEvent;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github._4drian3d.signedvelocity.minestom.listener;

import io.github._4drian3d.signedvelocity.common.SignedQueue;
import io.github._4drian3d.signedvelocity.common.queue.SignedQueue;
import io.github._4drian3d.signedvelocity.minestom.SignedVelocity;
import net.minestom.server.entity.Player;
import net.minestom.server.event.player.PlayerCommandEvent;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.github._4drian3d.signedvelocity.minestom.listener;

import io.github._4drian3d.signedvelocity.common.SignedQueue;
import io.github._4drian3d.signedvelocity.common.SignedResult;
import io.github._4drian3d.signedvelocity.common.queue.SignedQueue;
import io.github._4drian3d.signedvelocity.common.queue.SignedResult;
import io.github._4drian3d.signedvelocity.minestom.SignedVelocity;
import net.minestom.server.event.player.PlayerPluginMessageEvent;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github._4drian3d.signedvelocity.paper;

import io.github._4drian3d.signedvelocity.common.SignedQueue;
import io.github._4drian3d.signedvelocity.common.PropertyHolder;
import io.github._4drian3d.signedvelocity.common.queue.SignedQueue;
import io.github._4drian3d.signedvelocity.paper.listener.*;
import it.unimi.dsi.fastutil.objects.ObjectArraySet;
import org.bukkit.Server;
Expand All @@ -17,6 +18,7 @@
import java.util.stream.Stream;

public final class SignedVelocity extends JavaPlugin {
private static final boolean LEGACY_PLUGIN_WARNING = PropertyHolder.readBoolean("io.github._4drian3d.signedvelocity.legacyPluginWarning", true);
public static final String CHANNEL = "signedvelocity:main";
private final SignedQueue chatQueue = new SignedQueue();
private final SignedQueue commandQueue = new SignedQueue();
Expand All @@ -40,7 +42,9 @@ public void onEnable() {
this,
listener.ignoreCancelled()
));
this.blameAboutLegacyPlugins();
if (LEGACY_PLUGIN_WARNING) {
this.blameAboutLegacyPlugins();
}
}

public SignedQueue getChatQueue() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github._4drian3d.signedvelocity.paper.listener;

import io.github._4drian3d.signedvelocity.common.SignedQueue;
import io.github._4drian3d.signedvelocity.common.queue.SignedQueue;
import io.github._4drian3d.signedvelocity.paper.SignedVelocity;
import io.papermc.paper.event.player.AsyncChatDecorateEvent;
import net.kyori.adventure.text.Component;
Expand Down Expand Up @@ -35,11 +35,9 @@ public void handle(@NotNull AsyncChatDecorateEvent event) {
this.chatQueue.dataFrom(player.getUniqueId())
.nextResultWithoutAdvance()
.thenAccept(result -> {
if (!result.cancelled()) {
final String modifiedChat = result.toModify();
if (modifiedChat != null) {
event.result(Component.text(modifiedChat));
}
final String modifiedChat = result.toModify();
if (modifiedChat != null) {
event.result(Component.text(modifiedChat));
}
}).join();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
package io.github._4drian3d.signedvelocity.paper.listener;

import io.github._4drian3d.signedvelocity.common.PropertyHolder;

public interface LocalExecutionDetector {
boolean CHECK_FOR_LOCAL_CHAT = check();
private static boolean check() {
final String property = System.getProperty("io.github._4drian3d.signedvelocity.checkForLocalChat");
if (property == null) {
return true;
} else {
return Boolean.parseBoolean(property);
}
}
boolean CHECK_FOR_LOCAL_CHAT = PropertyHolder.readBoolean("io.github._4drian3d.signedvelocity.checkForLocalChat", true);

boolean isLocal();
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github._4drian3d.signedvelocity.paper.listener;

import io.github._4drian3d.signedvelocity.common.SignedQueue;
import io.github._4drian3d.signedvelocity.common.queue.SignedQueue;
import io.github._4drian3d.signedvelocity.paper.SignedVelocity;
import io.papermc.paper.event.player.AsyncChatEvent;
import net.kyori.adventure.text.Component;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github._4drian3d.signedvelocity.paper.listener;

import io.github._4drian3d.signedvelocity.common.SignedQueue;
import io.github._4drian3d.signedvelocity.common.queue.SignedQueue;
import io.github._4drian3d.signedvelocity.paper.SignedVelocity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventPriority;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github._4drian3d.signedvelocity.paper.listener;

import io.github._4drian3d.signedvelocity.common.SignedQueue;
import io.github._4drian3d.signedvelocity.common.queue.SignedQueue;
import io.github._4drian3d.signedvelocity.paper.SignedVelocity;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerQuitEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteStreams;
import io.github._4drian3d.signedvelocity.common.SignedQueue;
import io.github._4drian3d.signedvelocity.common.SignedResult;
import io.github._4drian3d.signedvelocity.common.queue.SignedQueue;
import io.github._4drian3d.signedvelocity.common.queue.SignedResult;
import io.github._4drian3d.signedvelocity.paper.SignedVelocity;
import org.bukkit.entity.Player;
import org.bukkit.plugin.messaging.PluginMessageListener;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.google.inject.Inject;
import com.google.inject.name.Named;
import io.github._4drian3d.signedvelocity.common.SignedQueue;
import io.github._4drian3d.signedvelocity.common.queue.SignedQueue;
import io.github._4drian3d.signedvelocity.sponge.common.listener.SignedListener;
import net.kyori.adventure.text.Component;
import org.spongepowered.api.entity.living.player.server.ServerPlayer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.google.inject.Inject;
import com.google.inject.name.Named;
import io.github._4drian3d.signedvelocity.common.SignedQueue;
import io.github._4drian3d.signedvelocity.common.queue.SignedQueue;
import io.github._4drian3d.signedvelocity.sponge.common.listener.SignedListener;
import net.kyori.adventure.text.Component;
import org.spongepowered.api.entity.living.player.server.ServerPlayer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import com.google.inject.Inject;
import com.google.inject.name.Named;
import io.github._4drian3d.signedvelocity.common.SignedQueue;
import io.github._4drian3d.signedvelocity.common.SignedResult;
import io.github._4drian3d.signedvelocity.common.queue.SignedQueue;
import io.github._4drian3d.signedvelocity.common.queue.SignedResult;
import io.github._4drian3d.signedvelocity.sponge.common.listener.SignedListener;
import net.kyori.adventure.text.Component;
import org.spongepowered.api.entity.living.player.server.ServerPlayer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import com.google.inject.Inject;
import com.google.inject.name.Named;
import io.github._4drian3d.signedvelocity.common.SignedQueue;
import io.github._4drian3d.signedvelocity.common.SignedResult;
import io.github._4drian3d.signedvelocity.common.queue.SignedQueue;
import io.github._4drian3d.signedvelocity.common.queue.SignedResult;
import org.spongepowered.api.network.EngineConnection;
import org.spongepowered.api.network.channel.ChannelBuf;
import org.spongepowered.api.network.channel.raw.play.RawPlayDataHandler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.google.inject.Inject;
import com.google.inject.name.Named;
import io.github._4drian3d.signedvelocity.common.SignedQueue;
import io.github._4drian3d.signedvelocity.common.queue.SignedQueue;
import org.spongepowered.api.entity.living.player.server.ServerPlayer;
import org.spongepowered.api.event.EventContextKeys;
import org.spongepowered.api.event.EventListenerRegistration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.google.inject.Inject;
import com.google.inject.name.Named;
import io.github._4drian3d.signedvelocity.common.SignedQueue;
import io.github._4drian3d.signedvelocity.common.queue.SignedQueue;
import org.spongepowered.api.event.EventListenerRegistration;
import org.spongepowered.api.event.EventManager;
import org.spongepowered.api.event.Order;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.google.inject.AbstractModule;
import com.google.inject.name.Names;
import io.github._4drian3d.signedvelocity.common.SignedQueue;
import io.github._4drian3d.signedvelocity.common.queue.SignedQueue;

public final class SignedModule extends AbstractModule {
private final SignedQueue chatQueue = new SignedQueue();
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
group = io.github._4drian3d
version = 1.0.4-SNAPSHOT
version = 1.1.1-SNAPSHOT
description = Allows you to cancel or modify messages or commands from Velocity without synchronization problems
org.gradle.jvmargs=-Xmx2G
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@ public void register() {
return EventTask.withContinuation(continuation -> {
final RegisteredServer server = player.getCurrentServer()
.map(ServerConnection::getServer)
.orElseThrow();
.orElse(null);

// The player is not connected to a server, there is nothing I can do.
if (server == null) {
continuation.resume();
return;
}

// ALLOWED
// | If the command is allowed or will be redirected to the server,
// | simply transmit that the command should be accepted
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ public sealed interface PacketAdapter permits PacketEventsAdapter, VPacketEvents

static void register(final Injector injector, final PluginManager pluginManager) {
final Map<String, Class<? extends PacketAdapter>> adapters = Map.of(
// TODO: Re-enable when PacketEvents fixes its PostOrder problem on initialization
//"packetevents", PacketEventsAdapter.class,
"packetevents", PacketEventsAdapter.class,
"vpacketevents", VPacketEventsAdapter.class
// Probable support of protocolize?
);
Expand Down

0 comments on commit 32d38e3

Please sign in to comment.