-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.添加了将内容转换为翻译键值并复制到剪贴板的功能; 2.添加了将当前编辑的提示发送给所有玩家的功能
- Loading branch information
Showing
13 changed files
with
199 additions
and
42 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
41 changes: 41 additions & 0 deletions
41
src/main/java/com/teammoeg/frostedheart/base/client/gui/widget/ActionStateIconButton.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,41 @@ | ||
package com.teammoeg.frostedheart.base.client.gui.widget; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
import net.minecraft.client.gui.GuiGraphics; | ||
import net.minecraft.network.chat.Component; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* 按下后显示另一条信息的 IconButton | ||
*/ | ||
public class ActionStateIconButton extends IconButton { | ||
private final Component originalMessage; | ||
@Getter | ||
@Setter | ||
private Component clickedMessage; | ||
|
||
public ActionStateIconButton(int x, int y, Icon icon, int color, Component message, Component clickedMessage, OnPress pressedAction) { | ||
this(x, y, icon, color, 1, message, clickedMessage, pressedAction); | ||
} | ||
|
||
public ActionStateIconButton(int x, int y, Icon icon, int color, int scale, Component message, Component clickedMessage, OnPress pressedAction) { | ||
super(x, y, icon, color, scale, message, pressedAction); | ||
this.originalMessage = message; | ||
this.clickedMessage = clickedMessage; | ||
} | ||
|
||
@Override | ||
public void renderWidget(@NotNull GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) { | ||
super.renderWidget(graphics, mouseX, mouseY, partialTicks); | ||
if (!isHovered()) { | ||
setMessage(originalMessage); | ||
} | ||
} | ||
|
||
@Override | ||
public void onClick(double pMouseX, double pMouseY) { | ||
super.onClick(pMouseX, pMouseY); | ||
setMessage(clickedMessage); | ||
} | ||
} |
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
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
37 changes: 37 additions & 0 deletions
37
...in/java/com/teammoeg/frostedheart/content/tips/network/DisplayCustomTipRequestPacket.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,37 @@ | ||
package com.teammoeg.frostedheart.content.tips.network; | ||
|
||
import com.teammoeg.frostedheart.FHMain; | ||
import com.teammoeg.frostedheart.base.network.FHMessage; | ||
import com.teammoeg.frostedheart.content.tips.ServerTipSender; | ||
import com.teammoeg.frostedheart.content.tips.Tip; | ||
import com.teammoeg.frostedheart.util.lang.Lang; | ||
import net.minecraft.network.FriendlyByteBuf; | ||
import net.minecraftforge.network.NetworkEvent; | ||
|
||
import java.util.function.Supplier; | ||
|
||
public record DisplayCustomTipRequestPacket(Tip tip) implements FHMessage { | ||
|
||
public DisplayCustomTipRequestPacket(FriendlyByteBuf buffer) { | ||
this(Tip.builder("").fromNBT(buffer.readNbt()).build()); | ||
} | ||
|
||
@Override | ||
public void encode(FriendlyByteBuf buffer) { | ||
tip.write(buffer); | ||
} | ||
|
||
@Override | ||
public void handle(Supplier<NetworkEvent.Context> context) { | ||
var player = context.get().getSender(); | ||
if (player != null) { | ||
if (!player.hasPermissions(2)) { | ||
FHMain.LOGGER.warn("{} IS A HACKER!", player.getName().getString()); | ||
ServerTipSender.sendCustom(Tip.builder("warning").line(Lang.str("HACKER!")).pin(true).alwaysVisible(true).build(), player); | ||
} else { | ||
context.get().enqueueWork(() -> ServerTipSender.sendCustomToAll(tip)); | ||
} | ||
} | ||
context.get().setPacketHandled(true); | ||
} | ||
} |
Oops, something went wrong.