generated from Matt-MX/KtPaperPluginTemplate
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from Matt-MX/dev
Dev
- Loading branch information
Showing
11 changed files
with
91 additions
and
19 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
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
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
38 changes: 38 additions & 0 deletions
38
src/main/java/com/mattmx/nametags/hook/GlowingEffectHook.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,38 @@ | ||
package com.mattmx.nametags.hook; | ||
|
||
import com.github.retrooper.packetevents.event.PacketListenerAbstract; | ||
import com.github.retrooper.packetevents.event.PacketSendEvent; | ||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataType; | ||
import com.github.retrooper.packetevents.protocol.packettype.PacketType; | ||
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityMetadata; | ||
import com.mattmx.nametags.NameTags; | ||
import com.mattmx.nametags.entity.NameTagEntity; | ||
import me.tofaa.entitylib.meta.EntityMeta; | ||
import me.tofaa.entitylib.meta.Metadata; | ||
|
||
public class GlowingEffectHook extends PacketListenerAbstract { | ||
|
||
@Override | ||
public void onPacketSend(PacketSendEvent event) { | ||
if (event.getPacketType() == PacketType.Play.Server.ENTITY_METADATA) return; | ||
final WrapperPlayServerEntityMetadata packet = new WrapperPlayServerEntityMetadata(event); | ||
|
||
final NameTagEntity entity = NameTags.getInstance() | ||
.getEntityManager() | ||
.getNameTagEntityById(packet.getEntityId()); | ||
|
||
if (entity == null) return; | ||
|
||
Metadata meta = new Metadata(packet.getEntityId()); | ||
|
||
packet.getEntityMetadata().forEach((entry) -> meta.setIndex((byte) entry.getIndex(), (EntityDataType<Object>) entry.getType(), entry.getValue())); | ||
|
||
EntityMeta wrapper = new EntityMeta(packet.getEntityId(), meta); | ||
|
||
if (wrapper.isGlowing()) { | ||
entity.modify((tagMeta) -> { | ||
tagMeta.setSeeThrough(true); | ||
}); | ||
} | ||
} | ||
} |
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