feat: add actionbar message config option
This commit is contained in:
parent
a85b307edc
commit
a875356a1a
@ -19,6 +19,7 @@ import io.github.flemmli97.flan.player.LogoutTracker;
|
||||
import io.github.flemmli97.flan.player.PlayerClaimData;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.chat.ChatType;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.protocol.game.ClientboundSetSubtitleTextPacket;
|
||||
@ -34,6 +35,7 @@ import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||
import net.minecraft.world.level.levelgen.Heightmap;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -580,20 +582,28 @@ public class Claim implements IPermissionContainer {
|
||||
this.setDirty(true);
|
||||
}
|
||||
|
||||
public void displayEnterTitle(ServerPlayer player) {
|
||||
if (this.enterTitle != null) {
|
||||
player.connection.send(new ClientboundSetTitleTextPacket(this.enterTitle));
|
||||
if (this.enterSubtitle != null)
|
||||
player.connection.send(new ClientboundSetSubtitleTextPacket(this.enterSubtitle));
|
||||
private void displayTitleMessage(ServerPlayer player, Component title, @Nullable Component subtitle) {
|
||||
if (ConfigHandler.config.claimDisplayActionBar) {
|
||||
if (subtitle != null) {
|
||||
MutableComponent message = this.enterTitle.copy().append(" - ").append(this.enterSubtitle);
|
||||
player.sendSystemMessage(message, ChatType.GAME_INFO);
|
||||
return;
|
||||
}
|
||||
player.sendSystemMessage(this.enterTitle, ChatType.GAME_INFO);
|
||||
return;
|
||||
}
|
||||
player.connection.send(new ClientboundSetTitleTextPacket(this.enterTitle));
|
||||
if (subtitle != null) {
|
||||
player.connection.send(new ClientboundSetSubtitleTextPacket(this.enterSubtitle));
|
||||
}
|
||||
}
|
||||
|
||||
public void displayEnterTitle(ServerPlayer player) {
|
||||
displayTitleMessage(player, enterTitle, enterSubtitle);
|
||||
}
|
||||
|
||||
public void displayLeaveTitle(ServerPlayer player) {
|
||||
if (this.leaveTitle != null) {
|
||||
player.connection.send(new ClientboundSetTitleTextPacket(this.leaveTitle));
|
||||
if (this.leaveSubtitle != null)
|
||||
player.connection.send(new ClientboundSetSubtitleTextPacket(this.leaveSubtitle));
|
||||
}
|
||||
displayTitleMessage(player, leaveTitle, leaveSubtitle);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -45,6 +45,7 @@ public class Config {
|
||||
public Item inspectionItem = Items.STICK;
|
||||
|
||||
public int claimDisplayTime = 1000;
|
||||
public boolean claimDisplayActionBar = false;
|
||||
public int permissionLevel = 2;
|
||||
|
||||
public BuySellHandler buySellHandler = new BuySellHandler();
|
||||
|
Loading…
Reference in New Issue
Block a user