-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix large images kicking players * Improve tellraw selector filter I hope this is the last change that is required to satisfy everyone. This improves the selection filter to compare it to the second last node, which for tellraw should always be the selector! (This commit allow commands like `/execute ... run tellraw @A [{"text":"test"}]` to be broadcast.) * Update to 1.20.4 * Improve join / leave message events Moves join and leave message events to the actual broadcast to ensure better compatibility * Fix join message * Implement #67 resolves #67 * Update dependencies
- Loading branch information
Showing
17 changed files
with
183 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...pi/src/main/java/io/github/quiltservertools/blockbotapi/event/PlayerJoinMessageEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package io.github.quiltservertools.blockbotapi.event; | ||
|
||
import net.fabricmc.fabric.api.event.Event; | ||
import net.fabricmc.fabric.api.event.EventFactory; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
|
||
public interface PlayerJoinMessageEvent { | ||
Event<PlayerJoinMessageEvent> EVENT = EventFactory.createArrayBacked(PlayerJoinMessageEvent.class, (listeners) -> (player) -> { | ||
for (PlayerJoinMessageEvent listener : listeners) { | ||
listener.onPlayerJoinMessage(player); | ||
} | ||
}); | ||
|
||
void onPlayerJoinMessage(ServerPlayerEntity player); | ||
} |
15 changes: 15 additions & 0 deletions
15
...i/src/main/java/io/github/quiltservertools/blockbotapi/event/PlayerLeaveMessageEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package io.github.quiltservertools.blockbotapi.event; | ||
|
||
import net.fabricmc.fabric.api.event.Event; | ||
import net.fabricmc.fabric.api.event.EventFactory; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
|
||
public interface PlayerLeaveMessageEvent { | ||
Event<PlayerLeaveMessageEvent> EVENT = EventFactory.createArrayBacked(PlayerLeaveMessageEvent.class, (listeners) -> (player) -> { | ||
for (PlayerLeaveMessageEvent listener : listeners) { | ||
listener.onPlayerLeaveMessage(player); | ||
} | ||
}); | ||
|
||
void onPlayerLeaveMessage(ServerPlayerEntity player); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...ot-api/src/main/java/io/github/quiltservertools/blockbotapi/mixin/PlayerManagerMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package io.github.quiltservertools.blockbotapi.mixin; | ||
|
||
import io.github.quiltservertools.blockbotapi.event.PlayerJoinMessageEvent; | ||
import net.minecraft.network.ClientConnection; | ||
import net.minecraft.server.PlayerManager; | ||
import net.minecraft.server.network.ConnectedClientData; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(PlayerManager.class) | ||
public abstract class PlayerManagerMixin { | ||
@Inject( | ||
method = "onPlayerConnect", | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Lnet/minecraft/server/PlayerManager;broadcast(Lnet/minecraft/text/Text;Z)V" | ||
) | ||
) | ||
private void relayJoinMessageToDiscord(ClientConnection connection, ServerPlayerEntity player, ConnectedClientData clientData, CallbackInfo ci) { | ||
PlayerJoinMessageEvent.EVENT.invoker().onPlayerJoinMessage(player); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...ot-api/src/main/java/io/github/quiltservertools/blockbotapi/mixin/RandomCommandMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package io.github.quiltservertools.blockbotapi.mixin; | ||
|
||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation; | ||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; | ||
import io.github.quiltservertools.blockbotapi.event.ChatMessageEvent; | ||
import io.github.quiltservertools.blockbotapi.sender.MessageSender; | ||
import net.minecraft.server.PlayerManager; | ||
import net.minecraft.server.command.RandomCommand; | ||
import net.minecraft.server.command.ServerCommandSource; | ||
import net.minecraft.text.MutableText; | ||
import net.minecraft.text.Text; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
|
||
@Mixin(RandomCommand.class) | ||
public abstract class RandomCommandMixin { | ||
|
||
@WrapOperation( | ||
method = "execute", | ||
at = @At( | ||
value = "INVOKE", target = "Lnet/minecraft/server/PlayerManager;broadcast(Lnet/minecraft/text/Text;Z)V" | ||
) | ||
) | ||
private static void relayRandomRollToDiscord(PlayerManager instance, Text message, boolean overlay, Operation<Void> original, ServerCommandSource source) { | ||
original.call(instance, message, overlay); | ||
MessageSender sender = MessageSender.of(source, MessageSender.MessageType.ANNOUNCEMENT); | ||
ChatMessageEvent.EVENT.invoker().message( | ||
sender, | ||
// Change translation to literal | ||
Text.literal(message.getString()) | ||
); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...main/java/io/github/quiltservertools/blockbotapi/mixin/ServerPlayNetworkHandlerMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package io.github.quiltservertools.blockbotapi.mixin; | ||
|
||
import io.github.quiltservertools.blockbotapi.event.PlayerLeaveMessageEvent; | ||
import net.minecraft.server.network.ServerPlayNetworkHandler; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(ServerPlayNetworkHandler.class) | ||
public abstract class ServerPlayNetworkHandlerMixin { | ||
@Shadow | ||
public ServerPlayerEntity player; | ||
|
||
@Inject( | ||
method = "cleanUp", | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Lnet/minecraft/server/PlayerManager;broadcast(Lnet/minecraft/text/Text;Z)V" | ||
) | ||
) | ||
private void relayLeaveMessageToDiscord(CallbackInfo ci) { | ||
PlayerLeaveMessageEvent.EVENT.invoker().onPlayerLeaveMessage(this.player); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.