Skip to content

Commit

Permalink
fix: 尝试修复深拷贝失败导致的hook异常
Browse files Browse the repository at this point in the history
  • Loading branch information
Hellxd committed May 26, 2022
1 parent 3cc270b commit 3bee607
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.dionatestserver.pluginhooker.hook.impl.protocollib;

import com.comphenix.protocol.concurrency.SortedCopyOnWriteArray;
import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.events.PacketListener;
import com.comphenix.protocol.injector.PrioritizedListener;
Expand All @@ -11,6 +12,7 @@
import org.bukkit.plugin.Plugin;

import java.lang.reflect.Field;
import java.util.Collection;
import java.util.concurrent.ConcurrentHashMap;

public class ProtocolLibCallbackHandler {
Expand Down Expand Up @@ -52,7 +54,7 @@ private SortedPacketListenerList deepCopyListenerList(SortedPacketListenerList s
ConcurrentHashMap<Object, Object> listeners = (ConcurrentHashMap<Object, Object>) mapListeners.get(sortedPacketListenerList);
ConcurrentHashMap<Object, Object> resultMap = listeners.keySet().stream().collect(
ConcurrentHashMap::new,
(map, packetType) -> map.put(packetType, listeners.get(packetType)),
(map, packetType) -> map.put(packetType, new SortedCopyOnWriteArray((Collection) listeners.get(packetType))),
ConcurrentHashMap::putAll
);

Expand Down

0 comments on commit 3bee607

Please sign in to comment.