-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
syeyoung
committed
May 8, 2021
1 parent
5d1d86d
commit 293bb4f
Showing
10 changed files
with
225 additions
and
22 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
65 changes: 65 additions & 0 deletions
65
src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CustomNetworkPlayerInfo.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,65 @@ | ||
/* | ||
* Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod | ||
* Copyright (C) 2021 cyoung06 | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package kr.syeyoung.dungeonsguide.cosmetics; | ||
|
||
import com.mojang.authlib.GameProfile; | ||
import kr.syeyoung.dungeonsguide.DungeonsGuide; | ||
import kr.syeyoung.dungeonsguide.utils.TextUtils; | ||
import net.minecraft.client.network.NetworkPlayerInfo; | ||
import net.minecraft.network.play.server.S38PacketPlayerListItem; | ||
import net.minecraft.scoreboard.ScorePlayerTeam; | ||
import net.minecraft.util.ChatComponentText; | ||
import net.minecraft.util.IChatComponent; | ||
|
||
import java.util.List; | ||
|
||
public class CustomNetworkPlayerInfo extends NetworkPlayerInfo { | ||
public CustomNetworkPlayerInfo(GameProfile p_i46294_1_) { | ||
super(p_i46294_1_); | ||
} | ||
|
||
public CustomNetworkPlayerInfo(S38PacketPlayerListItem.AddPlayerData p_i46295_1_) { | ||
super(p_i46295_1_); | ||
} | ||
|
||
public IChatComponent getDisplayName() | ||
{ | ||
String semi_name = super.getDisplayName() != null ? super.getDisplayName().getFormattedText() : ScorePlayerTeam.formatPlayerName(super.getPlayerTeam(), super.getGameProfile().getName()); | ||
|
||
String actualName = ""; | ||
for (String s : semi_name.split(" ")) { | ||
if (TextUtils.stripColor(s).startsWith("[")) continue; | ||
actualName = s; | ||
} | ||
List<ActiveCosmetic> activeCosmetics = DungeonsGuide.getDungeonsGuide().getCosmeticsManager().getActiveCosmeticByPlayerNameLowerCase().get(TextUtils.stripColor(actualName).toLowerCase()); | ||
|
||
|
||
|
||
if (activeCosmetics == null) return super.getDisplayName(); | ||
CosmeticData color=null; | ||
for (ActiveCosmetic activeCosmetic : activeCosmetics) { | ||
CosmeticData cosmeticData = DungeonsGuide.getDungeonsGuide().getCosmeticsManager().getCosmeticDataMap().get(activeCosmetic.getCosmeticData()); | ||
if (cosmeticData.getCosmeticType().equals("color")) color = cosmeticData; | ||
} | ||
|
||
if (color != null) semi_name = semi_name.replace(actualName, color.getData()+actualName); | ||
|
||
return new ChatComponentText(semi_name); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CustomPacketPlayerListItem.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,39 @@ | ||
/* | ||
* Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod | ||
* Copyright (C) 2021 cyoung06 | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package kr.syeyoung.dungeonsguide.cosmetics; | ||
|
||
import kr.syeyoung.dungeonsguide.events.PlayerListItemPacketEvent; | ||
import net.minecraft.network.Packet; | ||
import net.minecraft.network.play.INetHandlerPlayClient; | ||
import net.minecraft.network.play.server.S38PacketPlayerListItem; | ||
import net.minecraftforge.common.MinecraftForge; | ||
|
||
public class CustomPacketPlayerListItem extends S38PacketPlayerListItem { | ||
public CustomPacketPlayerListItem(S38PacketPlayerListItem packet) { | ||
super(packet.getAction()); | ||
getEntries().addAll(packet.getEntries()); | ||
} | ||
|
||
@Override | ||
public void processPacket(INetHandlerPlayClient handler) { | ||
super.processPacket(handler); | ||
|
||
MinecraftForge.EVENT_BUS.post(new PlayerListItemPacketEvent(this)); | ||
} | ||
} |
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
30 changes: 30 additions & 0 deletions
30
src/main/java/kr/syeyoung/dungeonsguide/events/PlayerListItemPacketEvent.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,30 @@ | ||
/* | ||
* Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod | ||
* Copyright (C) 2021 cyoung06 | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package kr.syeyoung.dungeonsguide.events; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import net.minecraft.network.play.server.S38PacketPlayerListItem; | ||
import net.minecraftforge.fml.common.eventhandler.Event; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
public class PlayerListItemPacketEvent extends Event { | ||
private S38PacketPlayerListItem packetPlayerListItem; | ||
} |
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