Hotfix AntiCursorReCentering
Dieser Commit ist enthalten in:
Ursprung
41ed83dfe0
Commit
d1ff80b9dc
@ -21,16 +21,44 @@ package de.steamwar.bausystem.features.world;
|
|||||||
|
|
||||||
import com.comphenix.tinyprotocol.Reflection;
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||||
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.linkage.api.Enable;
|
import de.steamwar.linkage.api.Enable;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class AntiCursorReCentering implements Enable {
|
public class AntiCursorReCentering implements Enable {
|
||||||
|
|
||||||
|
private final Set<Player> CLOSE_PACKETS = new HashSet<>();
|
||||||
|
private final Set<Player> CLOSE_NOW = new HashSet<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enable() {
|
public void enable() {
|
||||||
// Fix GUI Closing causing a recentering of the Cursor
|
Class<?> closeWindow = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutCloseWindow");
|
||||||
Class<?> clazz = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutCloseWindow");
|
TinyProtocol.instance.addFilter(closeWindow, (player, object) -> {
|
||||||
TinyProtocol.instance.addFilter(clazz, (player, object) -> null);
|
if (CLOSE_NOW.remove(player)) {
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
CLOSE_PACKETS.add(player);
|
||||||
|
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||||
|
if (CLOSE_PACKETS.remove(player)) {
|
||||||
|
CLOSE_NOW.add(player);
|
||||||
|
TinyProtocol.instance.sendPacket(player, object);
|
||||||
|
}
|
||||||
|
}, 0);
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
|
||||||
|
Class<?> openWindow = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutOpenWindow");
|
||||||
|
TinyProtocol.instance.addFilter(openWindow, (player, object) -> {
|
||||||
|
CLOSE_PACKETS.remove(player);
|
||||||
|
return object;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren