-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
6 changed files
with
59 additions
and
46 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
46 changes: 46 additions & 0 deletions
46
src/main/java/net/rayfall/eyesniper2/skRayFall/utli/ProtocolLibUtli.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,46 @@ | ||
package net.rayfall.eyesniper2.skRayFall.utli; | ||
|
||
import net.rayfall.eyesniper2.skRayFall.skRayFall; | ||
|
||
import org.bukkit.enchantments.Enchantment; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.inventory.ItemStack; | ||
|
||
import com.comphenix.protocol.PacketType; | ||
import com.comphenix.protocol.ProtocolLibrary; | ||
import com.comphenix.protocol.events.ListenerPriority; | ||
import com.comphenix.protocol.events.PacketAdapter; | ||
import com.comphenix.protocol.events.PacketEvent; | ||
import com.comphenix.protocol.wrappers.nbt.NbtCompound; | ||
import com.comphenix.protocol.wrappers.nbt.NbtFactory; | ||
|
||
public class ProtocolLibUtli implements Listener{ | ||
public static void addGlow(ItemStack[] stacks) { | ||
for (ItemStack stack : stacks) { | ||
if (stack != null) { | ||
if (stack.getEnchantmentLevel(Enchantment.ARROW_INFINITE) == 70 || stack.getEnchantmentLevel(Enchantment.WATER_WORKER) == 70) { | ||
NbtCompound compound = (NbtCompound) NbtFactory.fromItemTag(stack); | ||
compound.put(NbtFactory.of("HideFlags", 1)); | ||
} | ||
} | ||
} | ||
} | ||
|
||
public static void run() { | ||
|
||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(new PacketAdapter.AdapterParameteters().plugin(skRayFall.plugin).serverSide().listenerPriority(ListenerPriority.HIGH).types(PacketType.Play.Server.SET_SLOT, PacketType.Play.Server.WINDOW_ITEMS)) { | ||
@Override | ||
public void onPacketSending(PacketEvent event) { | ||
if (event.getPacketType() == PacketType.Play.Server.SET_SLOT) { | ||
addGlow(new ItemStack[] { event.getPacket().getItemModifier().read(0) }); | ||
} else { | ||
addGlow(event.getPacket().getItemArrayModifier().read(0)); | ||
} | ||
} | ||
}); | ||
|
||
} | ||
|
||
} | ||
|
||
|
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