mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2026-01-04 15:41:40 +00:00
ClassInstanceMultiMap belongs to Minecraft vanilla entity storage. And is unused, since replaced by spottedleaf's entity storage (rewrite chunk system). However these patches might be useful for vanilla entity storage if is used.
57 lines
3.9 KiB
Diff
57 lines
3.9 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
|
Date: Fri, 23 Dec 2022 22:22:47 +0100
|
|
Subject: [PATCH] Replace throttle tracker map with optimized collection
|
|
|
|
License: MIT (https://opensource.org/licenses/MIT)
|
|
Gale - https://galemc.org
|
|
|
|
This patch is based on the following patch:
|
|
"Use more fastutil data structures"
|
|
By: nopjmp <kthompson@hey.com>
|
|
As part of: Dionysus (https://github.com/nopjmp/Dionysus)
|
|
Licensed under: MIT (https://opensource.org/licenses/MIT)
|
|
|
|
* Dionysus description *
|
|
|
|
Use them in more places.
|
|
|
|
* Dionysus copyright *
|
|
|
|
Copyright 2021 Kayla Thompson
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
|
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
|
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
|
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
|
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
diff --git a/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java b/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
|
|
index 8054aad7f394db8257fc894d92a6993283b8dbd4..0eaa9c9bae27ca91c3685c7b49a8cc82a6b9bd40 100644
|
|
--- a/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
|
|
+++ b/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
|
|
@@ -20,7 +20,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL
|
|
static final java.util.regex.Pattern PROP_PATTERN = java.util.regex.Pattern.compile("\\w{0,16}");
|
|
// Spigot end
|
|
// Paper start - Connection throttle
|
|
- private static final java.util.Map<java.net.InetAddress, Long> throttleTracker = new java.util.HashMap<>();
|
|
+ private static final it.unimi.dsi.fastutil.objects.Object2LongMap<java.net.InetAddress> throttleTracker = new it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap<>(); // Gale - Dionysus - replace throttle tracker map with optimized collection
|
|
private static int throttleCounter = 0;
|
|
// Paper end - Connection throttle
|
|
private static final boolean BYPASS_HOSTCHECK = Boolean.getBoolean("Paper.bypassHostCheck"); // Paper
|
|
@@ -80,7 +80,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL
|
|
java.net.InetAddress address = socketAddress.getAddress();
|
|
|
|
synchronized (ServerHandshakePacketListenerImpl.throttleTracker) {
|
|
- if (ServerHandshakePacketListenerImpl.throttleTracker.containsKey(address) && currentTime - ServerHandshakePacketListenerImpl.throttleTracker.get(address) < connectionThrottle) {
|
|
+ if (ServerHandshakePacketListenerImpl.throttleTracker.containsKey(address) && currentTime - ServerHandshakePacketListenerImpl.throttleTracker.getLong(address) < connectionThrottle) { // Gale - Dionysus - replace throttle tracker map with optimized collection
|
|
ServerHandshakePacketListenerImpl.throttleTracker.put(address, currentTime);
|
|
Component chatmessage = io.papermc.paper.adventure.PaperAdventure.asVanilla(io.papermc.paper.configuration.GlobalConfiguration.get().messages.kick.connectionThrottle);
|
|
this.connection.send(new ClientboundLoginDisconnectPacket(chatmessage));
|