Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-18 12:30:06 +01:00
Add basic sendTitle / resetTitle API.
More APIs to follow pending feedback of whether this is the preferred implementation. Methods marked as deprecated and subject to change, but work as is.
Dieser Commit ist enthalten in:
Ursprung
f27339caf8
Commit
a03743b3b4
@ -21,6 +21,7 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import net.minecraft.server.*;
|
import net.minecraft.server.*;
|
||||||
|
import net.minecraft.server.PacketPlayOutTitle.EnumTitleAction;
|
||||||
|
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.apache.commons.lang.NotImplementedException;
|
import org.apache.commons.lang.NotImplementedException;
|
||||||
@ -1326,4 +1327,23 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||||||
Preconditions.checkArgument(getGameMode() == GameMode.SPECTATOR, "Player must be in spectator mode");
|
Preconditions.checkArgument(getGameMode() == GameMode.SPECTATOR, "Player must be in spectator mode");
|
||||||
getHandle().setSpectatorTarget((entity == null) ? null : ((CraftEntity) entity).getHandle());
|
getHandle().setSpectatorTarget((entity == null) ? null : ((CraftEntity) entity).getHandle());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendTitle(String title, String subtitle) {
|
||||||
|
if (title != null) {
|
||||||
|
PacketPlayOutTitle packetTitle = new PacketPlayOutTitle(EnumTitleAction.TITLE, CraftChatMessage.fromString(title)[0]);
|
||||||
|
getHandle().playerConnection.sendPacket(packetTitle);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (subtitle != null) {
|
||||||
|
PacketPlayOutTitle packetSubtitle = new PacketPlayOutTitle(EnumTitleAction.SUBTITLE, CraftChatMessage.fromString(subtitle)[0]);
|
||||||
|
getHandle().playerConnection.sendPacket(packetSubtitle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void resetTitle() {
|
||||||
|
PacketPlayOutTitle packetReset = new PacketPlayOutTitle(EnumTitleAction.RESET, null);
|
||||||
|
getHandle().playerConnection.sendPacket(packetReset);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren