Skip to content

Commit 2060408

Browse files
committed
started on ignoring endedragon wing packets
1 parent 9b5eea4 commit 2060408

File tree

3 files changed

+16
-18
lines changed

3 files changed

+16
-18
lines changed

src/main/java/tech/nully/BossBarAPI/BossBar.java

-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ public void display() {
5353
}
5454
dragon = new SpawnFakeWither.FakeWither(p, ProtocolLibrary.getProtocolManager());
5555
dragon.setCustomName(text);
56-
dragon.setVisible(false);
5756
dragon.create();
5857

5958
t = new TeleportScheduler(this);

src/main/java/tech/nully/BossBarAPI/Main.java

+14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
package tech.nully.BossBarAPI;
22

3+
import com.comphenix.packetwrapper.Packet3ENamedSoundEffect;
4+
import com.comphenix.protocol.PacketType;
5+
import com.comphenix.protocol.ProtocolLibrary;
6+
import com.comphenix.protocol.events.PacketAdapter;
7+
import com.comphenix.protocol.events.PacketContainer;
8+
import com.comphenix.protocol.events.PacketEvent;
9+
import net.minecraft.server.v1_5_R3.Packet62NamedSoundEffect;
310
import org.bukkit.plugin.Plugin;
411
import org.bukkit.plugin.java.JavaPlugin;
512

@@ -15,6 +22,13 @@ public void onEnable() {
1522
instance = this;
1623
System.out.println("BossBar is on");
1724
getCommand("bossbar").setExecutor(new FakeWitherCommand());
25+
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(this, PacketType.Play.Server.NAMED_SOUND_EFFECT) {
26+
@Override
27+
public void onPacketSending(PacketEvent event) {
28+
PacketContainer cont = new PacketContainer(event.getPacketType());
29+
//TODO
30+
}
31+
});
1832
}
1933

2034
// Overrides onDisable

src/main/java/tech/nully/BossBarAPI/SpawnFakeWither.java

+2-17
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import com.comphenix.packetwrapper.Packet1DDestroyEntity;
55
import com.comphenix.packetwrapper.Packet28EntityMetadata;
66
import com.comphenix.protocol.ProtocolManager;
7-
import com.comphenix.protocol.events.PacketContainer;
87
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
98
import org.bukkit.Bukkit;
109
import org.bukkit.Location;
@@ -21,8 +20,6 @@ public class SpawnFakeWither extends JavaPlugin {
2120
// You could also use a full-fledged API like RemoteEntities
2221
public static class FakeWither {
2322
public static final byte INVISIBLE = 0x20;
24-
// Just a guess
25-
public static final int HEALTH_RANGE = 80 * 80;
2623
// Next entity ID
2724
public static int NEXT_ID = 6000;
2825

@@ -37,8 +34,6 @@ public static class FakeWither {
3734
public int id = NEXT_ID++;
3835
// Default health
3936
public int health = 300;
40-
41-
public boolean visible;
4237
public String customName;
4338
public boolean created;
4439

@@ -67,17 +62,6 @@ public void setHealth(int health) {
6762
this.health = health;
6863
}
6964

70-
public void setVisible(boolean visible) {
71-
// Make visible or invisible
72-
if (created) {
73-
WrappedDataWatcher watcher = new WrappedDataWatcher();
74-
75-
watcher.setObject(METADATA_FLAGS, visible ? (byte) 0 : INVISIBLE);
76-
sendMetadata(watcher);
77-
}
78-
this.visible = visible;
79-
}
80-
8165
public void setCustomName(String name) {
8266
if (created) {
8367
WrappedDataWatcher watcher = new WrappedDataWatcher();
@@ -116,9 +100,10 @@ public void create() {
116100
Packet18SpawnMob spawnMob = new Packet18SpawnMob();
117101
WrappedDataWatcher watcher = new WrappedDataWatcher();
118102

119-
watcher.setObject(METADATA_FLAGS, visible ? (byte) 0 : INVISIBLE);
103+
watcher.setObject(METADATA_FLAGS, INVISIBLE);
120104
watcher.setObject(METADATA_WITHER_HEALTH, (int) health); // 1.5.2 -> Change to (int)
121105

106+
122107
if (customName != null) {
123108
watcher.setObject(METADATA_NAME, customName);
124109
watcher.setObject(METADATA_SHOW_NAME, (byte) 1);

0 commit comments

Comments
 (0)