|
1 | | -package com.github.katorly.starlinutils.festival; |
| 1 | +// package com.github.katorly.starlinutils.festival; |
2 | 2 |
|
3 | | -import java.text.SimpleDateFormat; |
4 | | -import java.util.Objects; |
| 3 | +// import java.text.SimpleDateFormat; |
| 4 | +// import java.util.Objects; |
5 | 5 |
|
6 | | -import com.comphenix.protocol.PacketType; |
7 | | -import com.comphenix.protocol.events.*; |
8 | | -import com.comphenix.protocol.injector.GamePhase; |
9 | | -import com.comphenix.protocol.wrappers.EnumWrappers; |
10 | | -import com.comphenix.protocol.wrappers.WrappedChatComponent; |
11 | | -import com.github.katorly.starlinutils.StarlinUtils; |
| 6 | +// import com.comphenix.protocol.PacketType; |
| 7 | +// import com.comphenix.protocol.events.*; |
| 8 | +// import com.comphenix.protocol.injector.GamePhase; |
| 9 | +// import com.comphenix.protocol.wrappers.EnumWrappers; |
| 10 | +// import com.comphenix.protocol.wrappers.WrappedChatComponent; |
| 11 | +// import com.github.katorly.starlinutils.StarlinUtils; |
12 | 12 |
|
13 | | -import net.md_5.bungee.api.ChatColor; |
14 | | -import net.md_5.bungee.api.chat.BaseComponent; |
15 | | -import net.md_5.bungee.api.chat.TextComponent; |
16 | | -import net.md_5.bungee.chat.ComponentSerializer; |
| 13 | +// import net.md_5.bungee.api.ChatColor; |
| 14 | +// import net.md_5.bungee.api.chat.BaseComponent; |
| 15 | +// import net.md_5.bungee.api.chat.TextComponent; |
| 16 | +// import net.md_5.bungee.chat.ComponentSerializer; |
17 | 17 |
|
18 | | -public class ClearAndBright { |
19 | | - public static boolean isToday(String date) { |
20 | | - long t = System.currentTimeMillis(); |
21 | | - SimpleDateFormat d = new SimpleDateFormat("MM-dd"); |
22 | | - String n = d.format(t); |
23 | | - if (Objects.equals(n, date)) |
24 | | - return true; |
25 | | - else |
26 | | - return false; |
27 | | - } |
| 18 | +// public class ClearAndBright { |
| 19 | +// public static boolean isToday(String date) { |
| 20 | +// long t = System.currentTimeMillis(); |
| 21 | +// SimpleDateFormat d = new SimpleDateFormat("MM-dd"); |
| 22 | +// String n = d.format(t); |
| 23 | +// if (Objects.equals(n, date)) |
| 24 | +// return true; |
| 25 | +// else |
| 26 | +// return false; |
| 27 | +// } |
28 | 28 |
|
29 | | - public static void grayChatting() { |
30 | | - StarlinUtils.cab.addPacketListener(new PacketAdapter(PacketAdapter.params().plugin(StarlinUtils.INSTANCE).serverSide().listenerPriority(ListenerPriority.NORMAL).gamePhase(GamePhase.PLAYING).optionAsync().options(ListenerOptions.SKIP_PLUGIN_VERIFIER).types(PacketType.Play.Server.CHAT)) { |
31 | | - @Override |
32 | | - public void onPacketSending(PacketEvent event) { |
33 | | - if (isToday("04-05")) { |
34 | | - PacketContainer packet = event.getPacket(); |
35 | | - PacketType packetType = event.getPacketType(); |
36 | | - if (packetType.equals(PacketType.Play.Server.CHAT)) { |
37 | | - if (packet.getChatTypes() == null) return; |
38 | | - if (packet.getChatTypes().getValues().get(0) != EnumWrappers.ChatType.SYSTEM) return; |
39 | | - WrappedChatComponent warppedComponent = packet.getChatComponents().getValues().get(0); |
40 | | - String json = warppedComponent.getJson(); |
41 | | - BaseComponent[] components = ComponentSerializer.parse(json); |
42 | | - components = TextComponent.fromLegacyText(TextComponent.toLegacyText(components)); |
43 | | - for(BaseComponent component:components) component.setColor(ChatColor.GRAY); |
44 | | - String newJson = ComponentSerializer.toString(components); |
45 | | - warppedComponent.setJson(newJson); |
46 | | - packet.getChatComponents().write(0, warppedComponent); |
47 | | - } |
48 | | - } |
49 | | - } |
50 | | - }); |
51 | | - } |
52 | | -} |
| 29 | +// public static void grayChatting() { |
| 30 | +// StarlinUtils.cab.addPacketListener(new PacketAdapter(PacketAdapter.params().plugin(StarlinUtils.INSTANCE).serverSide().listenerPriority(ListenerPriority.NORMAL).gamePhase(GamePhase.PLAYING).optionAsync().options(ListenerOptions.SKIP_PLUGIN_VERIFIER).types(PacketType.Play.Server.CHAT)) { |
| 31 | +// @Override |
| 32 | +// public void onPacketSending(PacketEvent event) { |
| 33 | +// if (isToday("04-05")) { //启用前请修改每年清明对应的时间 |
| 34 | +// PacketContainer packet = event.getPacket(); |
| 35 | +// PacketType packetType = event.getPacketType(); |
| 36 | +// if (packetType.equals(PacketType.Play.Server.CHAT)) { |
| 37 | +// if (packet.getChatTypes() == null) return; |
| 38 | +// if (packet.getChatTypes().getValues().get(0) != EnumWrappers.ChatType.SYSTEM) return; |
| 39 | +// WrappedChatComponent warppedComponent = packet.getChatComponents().getValues().get(0); |
| 40 | +// String json = warppedComponent.getJson(); |
| 41 | +// BaseComponent[] components = ComponentSerializer.parse(json); |
| 42 | +// components = TextComponent.fromLegacyText(TextComponent.toLegacyText(components)); |
| 43 | +// for(BaseComponent component:components) component.setColor(ChatColor.GRAY); |
| 44 | +// String newJson = ComponentSerializer.toString(components); |
| 45 | +// warppedComponent.setJson(newJson); |
| 46 | +// packet.getChatComponents().write(0, warppedComponent); |
| 47 | +// } |
| 48 | +// } |
| 49 | +// } |
| 50 | +// }); |
| 51 | +// } |
| 52 | +// } |
0 commit comments