2016-06-22 23:49:47 -04:00
|
|
|
/*
|
2022-04-14 03:42:00 +00:00
|
|
|
* Copyright (c) Forge Development LLC and contributors
|
2022-02-28 13:41:23 -08:00
|
|
|
* SPDX-License-Identifier: LGPL-2.1-only
|
2016-06-22 23:49:47 -04:00
|
|
|
*/
|
|
|
|
|
|
2012-10-28 06:58:23 -04:00
|
|
|
package net.minecraftforge.event;
|
|
|
|
|
|
2022-07-28 00:20:31 -05:00
|
|
|
import java.util.Objects;
|
|
|
|
|
import net.minecraft.network.chat.Component;
|
2021-11-26 05:09:56 +08:00
|
|
|
import net.minecraft.network.protocol.game.ServerboundChatPacket;
|
2021-07-17 00:08:49 -05:00
|
|
|
import net.minecraft.server.level.ServerPlayer;
|
2021-11-26 05:09:56 +08:00
|
|
|
import net.minecraftforge.common.MinecraftForge;
|
2018-06-10 21:12:46 -04:00
|
|
|
import net.minecraftforge.eventbus.api.Cancelable;
|
2022-06-07 16:03:52 -05:00
|
|
|
import net.minecraftforge.eventbus.api.Event;
|
2022-07-28 00:20:31 -05:00
|
|
|
import net.minecraftforge.fml.LogicalSide;
|
|
|
|
|
import org.jetbrains.annotations.ApiStatus;
|
Forge 1.19
* Bump pack.mcmeta formats
* 1.19 biome modifiers
* Mark ClientPlayerNetworkEvent.LoggedOutEvent's getters as nullable
* Add docs and package-info to client extension interfaces package
* Move RenderBlockOverlayEvent hooks to ForgeHooksClient
* Add package-infos to client events package
* Rename SoundLoadEvent to SoundEngineLoadEvent
This reduces confusion from consumers which may think the
name SoundLoadEvent refers to an individual sound being loaded rather
than the sound engine.
* Document and change SoundLoadEvent to fire on mod bus
Previously, it fired on both the mod bus and the Forge bus, which is
confusing for consumers.
* Delete SoundSetupEvent
Looking at its original implementation shows that there isn't an
appropriate place in the new sound code to reinsert the event, and the
place of 'sound engine/manager initialization event' is taken already by SoundLoadEvent.
* Perform some cleanup on client events
- Removed nullable annotations from ClientPlayerNetworkEvent
- Renamed #getPartialTicks methods to #getPartialTick, to be consistent
with vanilla's naming of the partial tick
- Cleanup documentation to remove line breaks, use the
spelling 'cancelled' over
'canceled', and improve docs on existing and
new methods.
* Remove EntityEvent.CanUpdate
Closes MinecraftForge/MinecraftForge#6394
* Switch to Jetbrains nullability annotations
* New PlayLevelSoundEvent; replaces old PlaySoundAtEntityEvent
* Remove ForgeWorldPresetScreens
* Remove IForgeRegistryEntry
* Remove use of List<Throwable> in FML's CompletableFutures
* Add docs to mod loading stages, stages, and phases
* Gradle 7.4.2
* Use SLF4J in FMLLoader and other subprojects
* Switch dynamic versions in subprojects to pinned ones
* Switch ForgeRoot and MDK to FG plugin markers
* Configure Forge javadoc task
The task now uses a custom stylesheet with MCForge elements, and
configured to combine the generation from the four FML subprojects
(fmlloader, fmlcore, javafmllanguage, mclanguage) and the Forge project
into the javadoc output.
* Update docs/md files, for 1.19 update and the move away from IRC to Discord.
* Make "Potentially dangerous alternative prefix" a debug warning, not info.
Co-authored-by: Curle <curle@gemwire.uk>
Co-authored-by: sciwhiz12 <arnoldnunag12@gmail.com>
Signed-off-by: SizableShrimp <sizableshrimp@sizableshrimp.me>
2022-06-07 15:31:26 -05:00
|
|
|
|
2014-07-06 16:07:49 -04:00
|
|
|
/**
|
2022-11-22 13:32:47 -06:00
|
|
|
* This event is fired whenever a {@link ServerboundChatPacket} is received from a client
|
|
|
|
|
* who has submitted their chat message.
|
2022-07-28 00:20:31 -05:00
|
|
|
* <p>
|
|
|
|
|
* This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
|
|
|
|
* If the event is cancelled, the message will not be sent to clients.
|
|
|
|
|
* <p>
|
|
|
|
|
* This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
|
|
|
|
* only on the {@linkplain LogicalSide#SERVER logical server}.
|
2014-07-06 16:07:49 -04:00
|
|
|
**/
|
2012-10-28 06:58:23 -04:00
|
|
|
@Cancelable
|
2025-10-12 00:14:47 +01:00
|
|
|
public final class ServerChatEvent extends Event
|
2013-02-15 03:22:59 -08:00
|
|
|
{
|
2022-06-07 16:03:52 -05:00
|
|
|
private final ServerPlayer player;
|
2022-07-28 00:20:31 -05:00
|
|
|
private final String username;
|
|
|
|
|
private final String rawText;
|
|
|
|
|
private Component message;
|
2022-06-07 16:03:52 -05:00
|
|
|
|
2022-07-28 00:20:31 -05:00
|
|
|
@ApiStatus.Internal
|
2022-11-22 13:32:47 -06:00
|
|
|
public ServerChatEvent(ServerPlayer player, String rawText, Component message)
|
2012-10-28 06:58:23 -04:00
|
|
|
{
|
|
|
|
|
this.player = player;
|
2022-07-28 00:20:31 -05:00
|
|
|
this.username = player.getGameProfile().getName();
|
|
|
|
|
this.rawText = rawText;
|
|
|
|
|
this.message = message;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* {@return the player who initiated the chat action}
|
|
|
|
|
*/
|
|
|
|
|
public ServerPlayer getPlayer()
|
|
|
|
|
{
|
|
|
|
|
return this.player;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* {@return the username of the player who initiated the chat action}
|
|
|
|
|
*/
|
|
|
|
|
public String getUsername()
|
|
|
|
|
{
|
|
|
|
|
return this.username;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* {@return the original raw text of the player chat message}
|
|
|
|
|
*/
|
|
|
|
|
public String getRawText()
|
|
|
|
|
{
|
|
|
|
|
return this.rawText;
|
2012-10-28 06:58:23 -04:00
|
|
|
}
|
2015-05-25 12:02:47 -07:00
|
|
|
|
2022-07-28 00:20:31 -05:00
|
|
|
/**
|
|
|
|
|
* Set the message to be sent to the relevant clients.
|
|
|
|
|
*/
|
|
|
|
|
public void setMessage(Component message)
|
2015-05-25 12:02:47 -07:00
|
|
|
{
|
2022-07-28 00:20:31 -05:00
|
|
|
this.message = Objects.requireNonNull(message);
|
2015-05-25 12:02:47 -07:00
|
|
|
}
|
2016-03-01 20:42:36 -08:00
|
|
|
|
2022-07-28 00:20:31 -05:00
|
|
|
/**
|
|
|
|
|
* {@return the message that will be sent to the relevant clients, if the event is not cancelled}
|
|
|
|
|
*/
|
|
|
|
|
public Component getMessage()
|
|
|
|
|
{
|
|
|
|
|
return this.message;
|
|
|
|
|
}
|
2012-10-28 06:58:23 -04:00
|
|
|
}
|