-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathActionBar.java
More file actions
31 lines (27 loc) · 1.03 KB
/
ActionBar.java
File metadata and controls
31 lines (27 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package Br.API;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.ProtocolManager;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.EnumWrappers;
import com.comphenix.protocol.wrappers.WrappedChatComponent;
import java.lang.reflect.InvocationTargetException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.entity.Player;
public class ActionBar {
public static void sendActionBar(Player p, String msg) {
if (msg == null) {
return;
}
ProtocolManager pm = ProtocolLibrary.getProtocolManager();
PacketContainer pc = new PacketContainer(PacketType.Play.Server.CHAT);
pc.getChatComponents().write(0, WrappedChatComponent.fromText(msg));
try {
pc.getChatTypes().write(0, EnumWrappers.ChatType.GAME_INFO);
} catch (Throwable e) {
pc.getBytes().write(0, (byte) 2);
}
pm.sendServerPacket(p, pc);
}
}